How to get the Google Analytics 360 Core Reporting API to return unsampled data

In this article I will show you a small Magic Trick, which will help you get unsampled data from the Google Analytics Core Reporting API.

Please note that this article is only aimed at Google Analytics 360 users, since it won’t work in the free version of Google Analytics. Google has confirmed this approach!

As a Google Analytics 360 user, you have 4 options when extracting data from the product:

In this article we will only focus on the use of the Core Reporting API.

Now you might be asking:

why use the Core Reporting API, when you can get unsampled data from the Unsampled API or BigQuery?”

The Core Reporting API is easy to use unlike the unsampled API where it returns a file path to a file you need to download and store before you can access the data and querying BigQuery can be hard if you don’t have SQL knowledge and it can even get expensive since you pay for querying data. In general the Core Reporting API is a lot easier to use when building queries and it’s free. The problem with the Core reporting API is that it often returns sampled data, especially when querying large datasets and you are using custom dimensions.

The Magic Trick

You have the following report that returns sampled data:

Dimensions:

  • Date (built-in)
  • Page (built-in)
  • Custom Dimension 5
  • Custom Dimension 20

Metrics:

  • Pageviews
  • Avg. Time on page

In this example the Core Reporting API returns sampled data…….. ARGHHHHHHH

Sampled data returned by the Google Analytics Core Reporting API

To fix this, you need to create a Custom Table with the exact same dimensions and metrics.

Building of the Custom Table in Google Analytics 360

Custom Tables essentially works in the same way as the normal Custom Reports but it has higher limits when it comes to sampling. I won’t go into details about Custom Tables but you can read more about them here.

When the Custom Table has been created, it might take some time before it contains data but when it’s filled with data, then go back to the Core Reporting API and try the same query and now the MAGIC happens! Now it should return unsampled data.

So what happening here? Just because we created a Custom Table with the same dimension we actually “force” Google to grab the unsampled data!

Custom Tables has these limit that might affect that you don’t get the expected result:

  • It can take up to 2 days before the table contains data
  • It only backfills 30 days of data

I know there is a lot of other workarounds to get unsampled data from the Core Reporting API but i like this because it’s clean and simple. Hopefully this trick will help a lot of you going forward.