Different totals for queries with multiple dimensions in Google Analytics data using googleanalyticsR

32 Views Asked by At

I'm analyzing Google Analytics 4 data using the R library googleanalyticsR. I can't figure out why changing the combination of dimensions results in consistently different absolute numbers. For example, the query with or without sessionsMedium gives me two different session numbers.

sessions <-ga_data(
  my_property_id,
  dimensions = c("date"),
  metrics = c("sessions"),
  date_range = c(from_date, oggi),
  dim_filters = ga_data_filter("country"=="Ireland"),
  limit = -1)

tot_sessions <- sum(sessions$sessions)

# 956 sessions

sessions_with_medium <-ga_data(
  my_property_id,
  dimensions = c("date","sessionMedium"),
  metrics = c("sessions"),
  date_range = c(from_date, oggi),
  dim_filters = ga_data_filter("country"=="Ireland"),
  limit = -1)

tot_sessions2 <- sum(sessions_with_medium$sessions)

#959 sessions

It's not an issue with those specific dimensions because the same happens, for instance, with the query for 'date' or for the combination of 'date' and 'region'. Could it be a sampling problem? From what I've been able to understand, though, it shouldn't be the case because the website visits aren't numerous, and the reports on Google Analytics appear as non-sampled. Also, in this example, the difference in numbers is small, but in other combinations, it becomes much larger.

Just to add further detail, I've tried running the same queries from https://ga-dev-tools.google/query-explorer/ and the results are the same. Therefore, I don't think it's an issue with the R library.

What could it be due to and how can I resolve it

0

There are 0 best solutions below