Discrepancies Between Google Analytics UI & Google Analytics API

776 views
Skip to first unread message

Michael Stitt

unread,
Apr 7, 2015, 3:27:50 PM4/7/15
to google-analytics...@googlegroups.com
I'm seeing a fairly large discrepancy between metrics within the UI compared to the same metrics pulled through the API.  I'm using the entire month of February (2/1/2015 - 2/28/2015) as the sample date range.

UI

When I run the Acquisition > Overview report I see 2,178,271 Sessions from Organic Search and 1.82 Pages / Session.  There is no notice at the top specifying the sample rate.

I then created a Custom Report where I used Pageviews, Sessions, Users as the Metrics and Default Channel Grouping as the Dimension.  That report generated 2,176,189 Sessions and 3,584,655 Pageviews, which equals 1.65 Pageviews/Session.  The notice at the top of the report says, "This report is based on 220,723 sessions (4.91% of sessions)."  That equates to 4.5M sessions (220,723 / 0.0491).

API

Here's how I setup the same report through the UI:
  • metrics = "ga:pageviews,ga:sessions,ga:users"
  • dimensions = "ga:channelGrouping"
  • samplingLevel = "HIGHER_PRECISION"
  • start_date = "2011-01-01"
  • end_date = "2015-02-28"
  • data = service.data().ga().get(
                    ids=ids,
                    start_date=month[0],
                    end_date=month[1],
                    metrics=metrics,
                    dimensions=dimensions,
                    samplingLevel=samplingLevel
                ).execute()

Looking at the Organic Search row I see we have 2,598,126 Sessions and 4,828,035 Pageviews, which equals 1.86 Pageviews/Session.

The sample size (data['sampleSpace']) returned is 6,877,979.  Are those PVs, Sessions, or Users?

The total results (data['totalForAllResults']) are:
  • 'ga:pageviews': '14,723,822'
  • 'ga:sessions': '6,877,980'
  • 'ga:users': '5,138,654'

The sample size appears to be much larger when querying through the API, however, the numbers don't match up to what I'm seeing through the UI.  Which method should I rely on for accurate metrics?  Is the report I'm generating through the API the same as the report I created through UI?

Thanks for any insight!



Michael Stitt

unread,
Apr 7, 2015, 5:36:20 PM4/7/15
to google-analytics...@googlegroups.com
I misspoke above: the sample size (data['sampleSize']) was 316,332 and the sample space (data['sampleSpace']) was 6,877,979.

Mike Sullivan

unread,
Apr 8, 2015, 11:38:14 AM4/8/15
to google-analytics...@googlegroups.com
do not rely on either - they are heavily sampled and segmented by channel grouping. The numbers are likely way off as far as month-to-month variations go. GA sampling will level the fluctuations out significantly.

Use multiple queries with smaller timescales and merge the results.
Reply all
Reply to author
Forward
0 new messages