Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtlynch/google-analytics-v4-example
A basic example of using the Google Analytics Core Reporting v4 API
https://github.com/mtlynch/google-analytics-v4-example
Last synced: 24 days ago
JSON representation
A basic example of using the Google Analytics Core Reporting v4 API
- Host: GitHub
- URL: https://github.com/mtlynch/google-analytics-v4-example
- Owner: mtlynch
- License: mit
- Created: 2020-01-20T15:16:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-20T15:49:02.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T10:18:24.165Z (5 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google-analytics-v4-example
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](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](https://console.cloud.google.com/apis/library/analyticsreporting.googleapis.com) in your Google Cloud Platform project.
### Creating a service account
1. Create a [service account](https://console.cloud.google.com/iam-admin/serviceaccounts) in Google Cloud Platform console for your project.
1. Assign the service account no permissions/roles.
1. Click "Create Key" to create a private key and save it in JSON format.
1. 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`.
1. Grant the user only "Read & Analyze" permissions.### Finding your Google Analytics View ID
1. In Google Analytics, open Admin > View > View Settings
1. Save the View ID displayed## Usage
```bash
go run main.go -viewID 123456789 -keyFile google-analytics-viewer-key.json
```