Skip to content

yuhong90/ga-reporting-v4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GAReportingV4 - Queries Samples

This repo serves as sample to use GA Reporting APIs v4 to query common basic analytics use cases on reporting website usage. Queried results are outputed as CSV files.

Examples of queries used:

  • Retrieves most visited pages for past 30 days
  • Retrieves most visited pages, breakdown by source for past 30 days
  • Retrieves most popular searched terms within site for past 30 days (WIP)
  • Retrieves most frequently referred pages and sources for past 30 days (WIP)

Setup Required for running as service application

  • Enable Analytics Reporting API v4 on your Google API Console
  • Create an service account and generate your service accounts keys
  • Add service account's email to GA account. Under GA's Settings > Account User Management > Property User Management >
  • Add service account keys and update .env files with keypath
  • Find your GA property's ViewId from GA's Settings > Account User Management > View Settings and update .env's GA_VIEW_ID (ga:<viewId>)

Running the script

  • npm install - Restore dependencies
  • npm run setup - Setup dir structure
  • npm run start - Run reporting script and write results as CSV to ./output dir

About

Sample queries using GA's reporting v4 apis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published