How to Configure Google Analytics as Data Source in Redash

Redash supports a number of data sources including MongoDB, MySQL, PostreSQL & Google Analytics. In this tutorial we will integrate Google Analytics with Redash and run sample queries. Earlier we had covered Redash installation on CentOS 6.

Step 1 – Service Account Creation

  1. Open service account page in Google Developer Console. Select a project. If you don’t have a project, create a new project.

  1. Create a new service account.
  2. Press continue and skip the optional step to grant users access to this service account. Create key using JSON type option. Download the key and store it in a safe and secure place.

Step 2 – Enabling Analytics API

Enable Analytics API

Step 3 – Enabling API Access in Google Analytics

Note down the service account email address. The email format is Add a new user in Google Analytics with this email address. This user should have Read & Analyse permission.

Step 4 – Configuring Data Source in Redash

Selection option to add Google analytics as data source. In JSON key file, select the json key downloaded in step 1.

Click on Test Connection button to test the connect.

Step 5 – Example Queries

Make sure to select analytics data source in left hand side dropdown while writing queries with google analytics as data source.

    "ids": "ga:12345678",
    "start_date": "30daysAgo",
    "end_date": "yesterday",
    "metrics": "ga:newUsers",
    "dimensions": "ga:date",
    "max_results": 20,
    "sort": "-ga:newUsers"