Analytics
4.6K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

API returns diff results for sessions vs. sessions & users as metrics

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

The API returns different results for sessions when calling using just sessions or sessions and users as metrics. Examples:

 

curl "https://www.googleapis.com/analytics/v3/data/ga?ids=<account_id>&dimensions=ga:campaignCode&metrics=ga:sessions,ga:users&start-date=2016-01-25&end-date=2016-01-25&max-results=10000&access_token=<access_token>"

 

vs

 

curl "https://www.googleapis.com/analytics/v3/data/ga?ids=<account_id>&dimensions=ga:campaignCode&metrics=ga:sessions&start-date=2016-01-25&end-date=2016-01-25&max-results=10000&access_token=<access_token>"

 

Could someone help me understand why does this happen. Is this somehow related to how sessions are accounted for, or could this be a bug in the API?

1 Expert replyverified_user

Re: API returns diff results for sessions vs. sessions & users as

Top Contributor
# 2
Top Contributor
I could not confirm this but my hunch is that Users metric does not play along nicely with sessions regarding campaignCode dimension. So if you request them separately, will they match what you can see from GA itself?
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: API returns diff results for sessions vs. sessions & users as

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Antti,

Thanks for the quick reply! Yep, if I request them separately, then it'll match to what we see in GA.

Just being curious, what's the reasoning behind your hunch? Shouldn't the metrics in the API still be independent of each other?

Re: API returns diff results for sessions vs. sessions & users as

Top Contributor
# 4
Top Contributor
I remember fighting similar type problems when I tried to bring session level metrics side by side with hit level metrics. I think user level is separate in that way too. I tried to confirm this with dimensions&metrics tool but no answer.

There is an article somewhere about this. I'll try to dig it up...
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: API returns diff results for sessions vs. sessions & users as

A T
Participant ✭ ✭ ✭
# 5
A T
Participant ✭ ✭ ✭

Re: API returns diff results for sessions vs. sessions & users as

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Hi Lauri,

This article explains why analyzing hit level metrics in tandem with session level metrics produces unexpected or apparently inaccurate results: http://help.analyticsedge.com/googleanalytics/misunderstood-metrics-events/

I'm not sure how this example using Sessions with Event and Events / Sessions with Event translates to your queries, if at all, though.

Maybe the problem has something to do with how campaign code is tracked, specifically that it'd be tracked once for each user (or, more accurately, persistent cookie or user ID, if you're using that feature), but multiple times for that user's sessions?

That is, if a user first arrives at your site from a given campaign, then visits 4 more times, they'd have sent 5 sessions total:
Assuming a user's initial referral source stays with their persistent cookie or user id (how they're tracked as a unique user):
- Sessions by Campaign ID = 5
- Users by Campaign ID = 1 - because, I assume, GA would count that user's unqiue id only once.


Does this explanation account for the discrepancy you're seeing?

Again, I'm not so sure of this, just my best guess based on my admittedly little experience. And I don't know how those API calls returns are different, specifically, what you expected from them, and how they differ from what you expected.

Still, I hope this helps somewhat. Sorry if not.

Good luck!