I'm working on a Google Analytics data extraction and I realized a difference in the results when I add a metric.
When I query the API like this https://www.googleapis.com/analytics/v3/data/ga?ids=ga:xxxxx&start-date=2018-12-01&end-date=2018-12-31&metrics=ga:totalEvents&dimensions=ga:eventLabel,ga:eventCategory,ga:eventAction&max-results=100&start-index=1&filters=ga:eventLabel=~théories et pratiques de l'enseignement programmé: guide à l'usage des enseignants
I receive this:
"totalsForAllResults": {
"ga:totalEvents": "23"
}
When I add ga:dateHourMinute
to the metrics, the same property returns 14
instead of 23
. Is there a way for me the get the right totalEvents, in this case it's 23, and also get the date and time in the same query?
From your comments we understand that you have reached the sampling threshold. Default reports are not subject to sampling. However, by applying a secondary dimension (in this case ga:dateHourMinute
), you required an ad-hoc queries so your data are subject to the thresholds for sampling, see here:
https://support.google.com/analytics/answer/2637192?hl=en
What you can do is query two shorter periods and then add the values of events together.