Skip to content

Instantly share code, notes, and snippets.

@mppatterson
Last active August 29, 2015 13:58
Show Gist options
  • Save mppatterson/9934762 to your computer and use it in GitHub Desktop.
Save mppatterson/9934762 to your computer and use it in GitHub Desktop.
How to Connect to Google Analytics API
Login to the Google account which has access to your analytics
Create an OAuth key on https://console.developers.google.com/
Store the keyfile in your app (and add it to gitignore)
Add your "xxx@developer.gserviceaccount.com" account to Google Analytics as a "Read & Analyze" user
Use the code from https://developers.google.com/analytics/solutions/articles/hello-analytics-api to get started
Use a service object instead of OAuth redirect (see: https://gist.github.com/mppatterson/9934981)
Full sample (in PHP) at: https://gist.github.com/mppatterson/9934917
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment