Requesting Unsampled Data from Google Analytics Using The Unsampled Reports API
You will need a trial license key or a Premium subscription to use the features discussed in this tutorial. If you haven’t already done so, sign-up for a free 30-day trial and instantly get your license key so you can begin.
If you are an existing customer, contact firstname.lastname@example.org to request a free 30-day trial of the Premium subscription.
You can download unsampled reports generated by Analytics Canvas or those defined within the Google Analytics web interface. To create the report within Analytics Canvas:
- Open Analytics Canvas and apply your license key (you only need to do this once)
- Go to New Source > Google Analytics and choose Create Unsampled Report
Note: You must permit both read and write access, and you must include permissions for either Google Drive or Google Cloud Storage. This is because Google writes the data to files, which must be stored, then accessed from within Canvas. Don’t worry, Canvas does this all programmatically.
- You will only be shown a list of Analytics 360 accounts and views that you can select from. Select the View you wish to query from and click Next.
- The Unsampled Reports API has a limit of 4 dimensions and 10 metrics per query.
- Make your query by selecting your dimensions and metrics.Complete your query by selecting the Time Period, applying existing segments or defining a new one, applying filters, and including any metadata to be included in your extract.
- Unsampled reports may take a very long time (from many minutes to hours) to complete. Often, while building a canvas and defining all queries, you may not wish to send many requests, but rather use the core API as a preview, then run the canvas and send requests when ready. If you wish to request unsampled data right away, check the checkbox labeled “Send unsampled report request on OK”, and as soon as the block is created a request will be made.
Data flow for unsampled reports
Unsampled reports follow a four-step process:
- The query is defined, and a preview is shown using the Core reporting API. This preview data may be sampled. This step is useful to let you modify the query, and the date range before you send the request for the unsampled data.
- Once the query is ready, the data set is requested via the unsampled API and the report is marked "Pending" and a unique id is assigned.
- When the report is ready, a CSV file is created on the users Google Drive
- The file is downloaded using the Google Drive API by Analytics Canvas and made available in the import block.
Analytics canvas automates this entire process.
When you are using Analytics canvas, you will see the following Icons to indicate what stage each query is in:
Query defined but not yet requested from the unsampled API:
Request to the unsampled API is pending:
Request to the unsampled API is pending:
Unsampled report is complete and downloaded:
Viewing unsampled reports statuses
If you go to the API Management menu, you will find a selection "Google Analytics Premium Unsampled reports".
If you have unsampled reports defined in the current canvas there will be a tab "Reports in this Canvas" that shows all the unsampled reports that are referenced in the current canvas, and their status.
If there are reports that have not yet been requested, the request(s) can be made either by pressing "Send request for all required reports" or by checking the reports you wish to send requests for and then pressing "Send request for checked reports".
If there are reports that are completed, and not yet downloaded, pressing "Download data for all completed reports" will run the canvas and fetch all data sets from Google Analytics.
Even if there are not any unsampled reports in the current canvas, the "All analytics canvas created reports" tab and a "web requested reports" tab will be present, and this provides a complete listing of all recently requested unsampled reports and their status for any selected profile.
Reports requested by Analytics Canvas will include full details of dimensions and metrics;
Web requested reports will show the current status:
Selecting this will allow you to request a list of all the recent outstanding reports requested and their status by clicking on a profile.
It is also possible to directly insert the data into the current canvas by selecting a query, and pressing the "import onto canvas" button.
Again, be aware of the Unsampled Reports API limits. You can only include 4 dimensions and 10 metrics, it will return up to 3 Million rows per query (no limit on sessions), and you can make up to 500 new reports per project, per day, to a maximum of 3500 unsampled reports.