Working with Google Analytics in Metabase
This page provides information on how to create and manage a connection to a Google Analytics dataset.
Setting up Google Analytics will require you to configure:
- A Google Cloud Platform (GCP) account.
- The Google Cloud Platform (GCP) console.
- Your Metabase admin settings.
Once you’ve configured Google Analytics in both places, you can check if your Google Analytics setup is working correctly.
You will need to have a Google Cloud Platform (GCP) account and create the project you would like to use in Metabase. Consult the Google Cloud Platform documentation on how to create and manage a project if you do not have one.
Google Cloud Platform: creating a service account and JSON file
You’ll first need a service account JSON file that Metabase can use to access your Google Analytics dataset. Service accounts are intended for non-human users (such as applications like Metabase) to authenticate (who am I?) and authorize (what can I do?) their API calls.
To create the service account JSON file, follow Google’s documentation on setting up service accounts for your Google Analytics dataset.
From your Google Cloud Platform console, go to IAM & Admin > Service accounts.
- Click + CREATE SERVICE ACCOUNT and fill out your service account details.
- Name the service account.
- Add a description (the service account ID will populate once you add a name).
Click Continue to skip the optional sections.
Click Done to create your service account.
- From the … menu, go to Manage keys > Add key.
- Select JSON for the key type.
- Click Create to download the JSON file to your computer. You can only download the key once.
- If you delete the key, you’ll need to create another service account with the same roles.
Add the service account to your Google Analytics account.
- Find the service account email by clicking into your service account name from IAM & Admin > Service accounts.
- The service account email will like:
- Only Read and Analyze permissions are needed for Metabase.
- Enable the Google Analytics API from the API overview.
- Check that you’re in the correct project before you click Enable.
- For further documentation please refer to Enable and disable APIs.
Metabase: adding a Google Analytics dataset
In your Metabase, click on Settings and select “Admin” to bring up the Admin Panel. In the Databases section, click on the Add database button, then select “Google Analytics” from the “Database type” dropdown and fill in the configuration settings:
Name is the title of your database in Metabase.
To get the Google Analytics Account ID, go to Google Analytics and click the Admin cog. In the admin tab, go to the Account Settings section: you will find the account ID below the “Basic Settings” heading.
Service account JSON file
Upload the service account JSON file you created when following the steps above. The JSON file contains the credentials your Metabase application will need to read and query your dataset.
Rerun queries for simple explorations: When this setting is enabled (which it is by default), Metabase automatically runs queries when users do simple explorations with the Summarize and Filter buttons when viewing a table or chart. You can turn this off if you find performance is slow. This setting doesn’t affect drill-throughs or SQL queries.
Choose when syncs and scans happen: When this setting is disabled (which it is by default), Metabase regularly checks the database to update its internal metadata. If you have a large database, we you can turn this on and control when and how often the field value scans happen.
Periodically refingerprint tables: This setting — disabled by default — enables Metabase to scan for additional field values during syncs allowing smarter behavior, like improved auto-binning on your bar charts.
Please see the database sync and analysis documentation for more details about these toggle settings.
Saving your database configuration
When you’re done, click the Save button. A modal dialog will inform you that your database has been added. You can click on Explore this data to see some automatic explorations of your data, or click I’m good thanks to stay in the Admin Panel.
Checking if Google Analytics is working correctly
Give Metabase some time to sync with your Google Analytics dataset, then exit the Admin Panel, click on Browse Data, find your Google Analytics database, and start exploring. Once Metabase is finished syncing, you will see the names of your Properties & Apps in the data browser.
If you’re having trouble, see the guides under Troubleshooting data sources.