Skip to content

Google Analytics

Display website visitors information from Google Analytics API

To make this work, you'll need a google API credential, link it to google analytics and find your website viewID.

  1. Open the Service accounts page and create a project named wtfutil.
  2. Navigation menu > IAM & admin > Service accounts
  3. Click add Create Service Account, enter a name (wtfutil) for the service account.
  4. The Service account permissions (optional) section that follows is not required. Click Continue.
  5. On the Grant users access to this service account screen, scroll down to the Create key section. Click add Create key.
  6. In the side panel that appears, select the format for your key: JSON.
  7. Click Create. Your new public/private key pair is generated and downloaded to your machine; it serves as the only copy of this key.
  8. Copy this json to indicated filepath in wtfutil googleanalytics module Configuration.
  9. Enable the Google Analytics APIS and Services (Navigation menu > APIS and Services > +Enable APIS and Services > Google Analytics Reporting API > Enable)

The newly created service account will have an email address that looks similar to:

Use this email address to add a user to the Google analytics view you want to access via the API (admin > user management > add users). Only Read & Analyze permissions are needed. Get the website viewID and put it in the config file.

Real Time Data

This module also supports displaying the number of visitors on each view live via the Google Analytics Real Time Reporting API Beta. In order to use this feature, you must sign up for the beta and wait for your whitelist application to be approved (which takes less than 24 hours). Once you're approved, all you need to do is set enableRealtime: true in the module settings.


  enabled: true
  enableRealtime: true
  months: 5
    top: 0
    left: 3
    width: 2
    height: 1
  refreshInterval: 400
  secretFile: "~/.config/wtf/google_analytics/client_secret.json"
    tessellation: "00000000" "111111111"


google analytics screenshot

Name Value
Optional When set to true, the live count of users on each listed view will be displayed in addition to historical visitor counts. This requires you to sign up for the Real Time Reporting API Beta. Default: false.
true, false.
The number of months being displayed with website session data.
Any positive integer.
Your Google client secret JSON file.
A string representing a file path to the JSON secret file.
Website(s) who will be displayed in the module, label does not have to corresponding to the actual url. Value must be the google analytics viewID of the website.
A string representing the viewID.

Source Code