Skip to content

Instantly share code, notes, and snippets.

@clkao
Created January 27, 2014 19:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clkao/8655960 to your computer and use it in GitHub Desktop.
Save clkao/8655960 to your computer and use it in GitHub Desktop.
jwt = new googleapis.auth.JWT do
SERVICE_ACCOUNT_EMAIL
KEYFILE_PEM
null
['https://www.googleapis.com/auth/analytics.readonly']
err, client <- googleapis.discover 'analytics', 'v3' .execute
err, result <- jwt.authorize
console.log result
err, result <- client.analytics.data.ga.get do
'ids': 'ga:XXXXXX'
'start-date': '2014-01-21'
'end-date': '2014-01-30'
'metrics': 'ga:visits'
'dimensions': 'ga:pagePathLevel2'
'sort': '-ga:visits'
'filters': 'ga:pagePathLevel1==/bills/'
'max-results': 25
.with-auth-client jwt
.execute
if err
console.log 'Error', err
console.log result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment