Skip to content

A basic example of using the Google Analytics Core Reporting v4 API

License

Notifications You must be signed in to change notification settings

mtlynch/google-analytics-v4-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-analytics-v4-example

License

Overview

This is an example of a simple console application that pulls pageview data from Google Analytics.

Pre-requisites

Enabling Google Analytics Reporting API

To query Google Analytics data, you'll need to enable the Google Analytics Reporting API in your Google Cloud Platform project.

Creating a service account

  1. Create a service account in Google Cloud Platform console for your project.
  2. Assign the service account no permissions/roles.
  3. Click "Create Key" to create a private key and save it in JSON format.
  4. In Google Analytics, open Admin > View > View User Management and add the email address of the service account you just created (it will have an email like [name]@[project ID].iam.gserviceaccount.com.
  5. Grant the user only "Read & Analyze" permissions.

Finding your Google Analytics View ID

  1. In Google Analytics, open Admin > View > View Settings
  2. Save the View ID displayed

Usage

go run main.go -viewID 123456789 -keyFile google-analytics-viewer-key.json

About

A basic example of using the Google Analytics Core Reporting v4 API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages