0

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.

2
  • For what it's worth, the sampling level key is not sampling-level, it's samplingLevel. (Unfortunately it's not consistent with the rest of the API...) Commented Jun 15, 2015 at 15:23
  • thanks for letting me know about that. It doesn't seem to have made too much difference, strangely. I think it must be something to do with the query. Is there any way to simply bring in all sessions, users, page views etc. for the selected time period, and not narrow them down by a dimension? Commented Jun 16, 2015 at 15:42

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the response, which is useful. I'm wondering how it is that I'm supposed to check whether the data is sampled? I've tried a few settings for the sampling level, but they seem to produce the same results; I'm guessing this is because the data set is relatively small. If I can't remove sampling entirely that's fine - the problem that I'm having is really that if I'm going to switch to the API rather than the dashboard, I'll need to prove that the results from the API are accurate and in line with what I was doing previously.
Also, one other thing - for some reason, January and February match up perfectly - months after that seem to have an issue
The API response will have a field that will tell you. You can also use the Query Explorer to run the sample query, and it will also tell you.
Thanks for your help; I checked on the query builder. The results were perfect and it stated they they did not contain sampled data. I'm unsure how to access this field in the API though, I'm afraid I'm rather new to working with it. I've edited my initial question to include these, if it's not too much trouble could you let me know where I'm going wrong? Thanks again for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.