Analytics
2.2K 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

ga:sessions returned by API is different then on GA site

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there.

Please help me to define a source of discrepancy in ga:sessions data I see.

Here is my query:

'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:' . $profile_id . '&dimensions=ga:date,ga:source,ga:medium,ga:channelGrouping&metrics=ga:sessions&start-date=' . $start_date . '&end-date=' . $end_date . '&max-results=10000&samplingLevel=HIGHER_PRECISION'.

When I pass '2016-09-01' - '2016-09-16' as $start_date and $end_date, I get next result:

[kind] => analytics#gaData
[id] => https://www.googleapis.com/analytics/v3/data/ga?ids=ga:xxx
&dimensions=ga:date,ga:source,ga:medium,ga:channelGrouping
&metrics=ga:sessions&start-date=2016-09-01
&end-date=2016-09-16&max-results=10000 [query] => Array ( [start-date] => 2016-09-01 [end-date] => 2016-09-16 [ids] => ga:50006378 [dimensions] => ga:date,ga:source,ga:medium,ga:channelGrouping [metrics] => Array ( [0] => ga:sessions ) [start-index] => 1 [max-results] => 10000 [samplingLevel] => HIGHER_PRECISION ) [itemsPerPage] => 10000 [totalResults] => 177 [containsSampledData] =>
The array with rows summary looks next:
    [2016-09-01] => 264
    [2016-09-02] => 237
    [2016-09-03] => 222
    [2016-09-04] => 54
    [2016-09-05] => 220
    [2016-09-06] => 485
    [2016-09-07] => 576
    [2016-09-08] => 267
    [2016-09-09] => 253
    [2016-09-10] => 236
    [2016-09-11] => 138
    [2016-09-12] => 335
    [2016-09-13] => 819
    [2016-09-14] => 790
    [2016-09-15] => 299
    [2016-09-16] => 311
Note that containsSampledData is false.

If I query data day-by-day, I get another result which matches GA site:
Day IndexSessions
9/1/2016264
9/2/2016237
9/3/2016222
9/4/201681
9/5/2016220
9/6/2016485
9/7/2016576
9/8/2016267
9/9/2016253
9/10/2016236
9/11/2016142
9/12/2016335
9/13/2016819
9/14/2016790
9/15/2016299
9/16/2016311
 

Sessions number for 9/4/2016 and 9/11/2016 differs.

Any ideas what can I do to get correct results for 16 days in a bunch will be appreciated.

Thanks!