Analytics API doesn't match web data

1.4k Views Asked by At

I understand that this is a question which has been asked elsewhere, but I haven't yet found an answer which is especially helpful.

The problem I'm having is that the data on the regular web version of analytics doesn't match the data I've pulled from the API.

From what I've read, this can sometimes be an issue with the type of query being used. Here's what I've been using:

  var requiredArguments = {    
'dimensions':'ga:medium',
'metrics': 'ga:users, ga:sessions, ga:uniquePageviews, ga:newUsers',
'sort': 'ga:medium',
'start-index': '1',
'max-results': '1000',
'sampling-level': 'DEFAULT',

};

and then...

  var results = Analytics.Data.Ga.get(    
tableId,
startDate, 
finishDate,
'ga:users, ga:sessions, ga:uniquePageviews, ga:newUsers',
requiredArguments);

Sessions, across a month, for instance, can sometimes vary by other 1000. I've tried using different sampling types; I don;t think it's that, because I'm not going over 50,000 sessions in a query.

Any help on this is much appreciated.

1

There are 1 best solutions below

4
On BEST ANSWER

You need to check the result returned if the data is sampled it will tell you the data is sampled.

"containsSampledData":false

samplingLevel

samplingLevel=DEFAULT Optional.
Use this parameter to set the sampling level (i.e. the number of sessions used to calculate the result) for a reporting query. The allowed values are consistent with the web interface and include:
DEFAULT — Returns response with a sample size that balances speed and accuracy.
FASTER — Returns a fast response with a smaller sample size.
HIGHER_PRECISION — Returns a more accurate response using a large sample size, but this may result in the response being slower.

If not supplied, the DEFAULT sampling level will be used. See the Sampling section for details on how to calculate the percentage of sessions that were used for a query.

Sampling should return results that are close but not exactly the same as the website. The only way to completely remove sampling from the API is to have a Premium Google Analytics Account

Also remember to consider processing latency. If you request data that is under 48 hours old it will also be different from the website.