Google Analytics Universal
Google Analytics was a web analytics service offered by Google that tracks and reports website traffic (now replaced with Google Analytics 4). This telescope obtained data from Google Analytics for 1 view id per publisher and for several combinations of metrics and dimensions. It is possible to add a regex expression to filter on pagepaths, so only data on relevant pagepaths is collected. Note that Google Analytics data is only available for the last 26 months, see Data retention - Analytics Help for more info.
To get access to the analytics data a publisher needs to add the relevant google service account as a user.
Custom dimensions for ANU Press
ANU Press was using custom dimensions in their google analytics data. To ensure that the telescope processes these custom dimensions, the organisation name needs to be set to exactly 'ANU Press'. The organisation name is used directly inside the telescope and if it matches 'ANU Press' additional dimensions will be added and a different BigQuery schema is used.
A note on the API metrics
We use the python client for the The Google Analytics API in order to retrieve the data on several metrics (such as page views) per country. It appears as though the API does not return a result for every country. We would have expected any data without a country field to be labelled with a country name of not set, however this does not appear to be the case. At this time, we have no other way of retrieving country-level data on the desired metrics, so we must acknowledge that the numbers returned by the API are slightly different to those found on the Google Analytics web page. A ticket has been created with google in the hope of resolving this issue.
Telescope kwargs
Organisation Name (organisation_name)
The name of the organisation as displayed on Google Analytics
View ID (view_id)
The View ID points to the specific view on which Google Analytics data is collected. See the google support page for more information on the hierarchy of the Analytics account.
Pagepath Regex (pagepath_regex)
This is a regular expression that is used to filter on pagepaths for which analytics data is collected. The regular expression can be set to an empty string if no filtering is required. Note that the Google Analytics API uses 're2', so it is not possible to use e.g. negative lookaheads. See the google support page and github wiki for more information.
Setting up service account
Create a service account from IAM & Admin - Service Accounts
Create a JSON key and download the file with key
For each organisation/publisher of interest, ask them to add this service account as a user for the correct view id
Airflow connections
Telescope Tasks
Data Download & Transform
Downloads a single month of reporting data using the GA3 analytics reporting API. Transforms the data from the report structure into the schema structure and saves it to a .jsonl file.
Big Query Load
The transformed data is loaded from the Google Cloud bucket into a partitioned BigQuery table under the google dataset (which will be created should it not exist yet). Since the data is partitioned on the release month, there will only be a single table named google_analytics3.
Table Schema
Last updated