Search code examples
google-analyticsgoogle-analytics-api

Pinging Google Analytics API v4 every few seconds shows fluctuations in total sessions


I'm pinging the Google Analytics API v4 every 3 seconds and grabbing the total sessions of 4 metro areas between the a single starting date and up to today.

dateRanges: [{
    startDate: '2019-08-14',
    endDate: 'today'
}],
metrics: [{
    expression: 'ga:sessions'
}],
dimensions: [{
    "name": "ga:metro"
}],

However, the reports that come back fluctuate up and down in total sessions, which is strange because total sessions shouldn't be able to go down.

I've attached a screenshot of the console.log output of total sessions reported back from the API every 3 seconds:

enter image description here

Is the reporting inaccurate when including the current day or am I retrieving data incorrectly?


Solution

  • Processing latency for Google Analytics data is 24-48 hours so there's no hope for getting accurate today's session numbers https://support.google.com/analytics/answer/1070983?hl=en#DataProcessingLatency Beside, pinging Reporting API every 3 seconds might deplete your API quota and that's not an intended use.