0
votes

I'm using Google Analytics Reporting API but I get sampled results even though the sessions in the specified date range are much less than the 500K limit. I have only ~4K sessions in a month.

I have also set "samplingLevel" as "LARGE".

Here's the Python query:

    response=analytics.reports().batchGet(
  body={
    "reportRequests":[
    {
      "viewId":myViewID,
      "dateRanges":[
        {
          "startDate":"2017-05-01",
          "endDate":"2017-05-30"
        }],
    "samplingLevel":"LARGE",
      "metrics":[
        {
          "expression":"ga:sessions"
        }],
      "dimensions": [
        {
          "name":"ga:browser"

        },
        {
          "name":"ga:city",
        }
        ]
      }]
  }
).execute()

As you can see below the sample space is 4365 sessions, much lesser than the 500K limit

response.get('reports', [])[0].get('data',[]).get('samplesReadCounts',[])
Out[31]: [u'2051']

response.get('reports', [])[0].get('data',[]).get('samplingSpaceSizes',[])
Out[32]: [u'4365']

Breaking the request into a smaller date range doesn't help either. I tried this using the GoogleAnalyticsR library in R with anti_sample=TRUE.

    > web_data <- google_analytics_4(view_id, 
+                                 date_range = c("2017-05-01", "2017-05-30"),
+                                 dimensions = c("city","browser"),
+                                 metrics = c("hits"),
+                                samplingLevel="LARGE",
+                                 anti_sample = TRUE)
2017-06-04 11:54:51> anti_sample set to TRUE. Mitigating sampling via multiple API calls.
2017-06-04 11:54:51> Finding how much sampling in data request...
2017-06-04 11:54:52> Downloaded [10] rows from a total of [15].
2017-06-04 11:54:52> Data is sampled, based on 47% of sessions.
2017-06-04 11:54:52> Finding number of sessions for anti-sample calculations...
2017-06-04 11:54:53> Downloaded [30] rows from a total of [30].
2017-06-04 11:54:53> Calculated [3] batches are needed to download approx. [18] rows unsampled.
2017-06-04 11:54:53> Anti-sample call covering 14 days: 2017-05-01, 2017-05-14
2017-06-04 11:54:54> Downloaded [7] rows from a total of [7].
2017-06-04 11:54:54> Data is sampled, based on 53.2% of sessions.
2017-06-04 11:54:54> Anti-sampling failed
2017-06-04 11:54:54> Anti-sample call covering 9 days: 2017-05-15, 2017-05-23
2017-06-04 11:54:54> Downloaded [4] rows from a total of [4].
2017-06-04 11:54:54> Data is sampled, based on 55.7% of sessions.
2017-06-04 11:54:54> Anti-sampling failed
2017-06-04 11:54:54> Anti-sample call covering 7 days: 2017-05-24, 2017-05-30
2017-06-04 11:54:55> Downloaded [10] rows from a total of [10].
2017-06-04 11:54:55> Data is sampled, based on 52.3% of sessions.
2017-06-04 11:54:55> Anti-sampling failed
Joining, by = c("city", "browser")
Joining, by = c("city", "browser")
2017-06-04 11:54:55> Finished unsampled data request, total rows [13]

When I check for the same data in a custom request, I see similar sampling

Custom report snapshot

Any idea why I get sampled results even thought the session count is much less than the limit?

3
I've got a similar problem: Since the beginning of June I only get sampled results when querying totalEvents by pagePath. Even when asking for only one day! The property does not have more than a few thousand sessions. But the hits are generated by Measurement Protocol. Maybe that's the reason. Last month I've fetched correct data. - JerryWho

3 Answers

1
votes

There's a ticket at Google about sampling despite low sessions at https://issuetracker.google.com/issues/62525952

0
votes

You have only 4k sessions in that View... but maybe that view is using filters... Check how much traffic you have in that property by looking at a view without filters.... The 500k sessions is at property Level not at view level.

0
votes

The 500k applies to Default Reports

Edit: 500k sessions at the property level for the date range you are using for ad-hoc queries.

Default reports explained:

Analytics has a set of preconfigured, default reports listed in the left pane under Audience, Acquisition, Behavior, and Conversions.

It looks like you are working with an ad-hoc report with secondary dimensions, so the 500k threshold probably doesn't apply anymore and is likely much lower. There is some more information on this in the page you originally linked to here.