Skip to content

Dumps google analytics data for all profiles, properties, and accounts into a csv using the javascript client library.

Notifications You must be signed in to change notification settings

harshadptl/google-analytics-dump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Analytics Dump

Dumps google analytics data for all profiles, properties, and accounts into a csv using the javascript client library.

API Keys

To apply for API access at the Google APIs Console:

  • Visit the Google APIs Console. Log in if prompted to do so.
  • Create a project for your application (if you have not already done so) by clicking Create project.
  • Select Services from the menu. The list of accessible Google services appears.
  • Scroll through the list until you find Google Analytics, click the Status switch next to the service name (so that it switches from OFF to ON.
  • For some services, the Console will display a Terms of Service pane. To go ahead, check the I agree to these terms box, then click Accept.
  • Scroll back to the top of the page and click API Access in the menu.
  • The API Access pane appears.
  • Click Create an OAuth 2.0 client ID.
  • The Create Client ID dialog appears.
  • Click the Web application radio button. Type your site or hostname in the field below.
  • Click more options under the radio buttons.
  • The Authorized Redirect URIs and Authorized JavaScript Origins fields appear.
  • Clear any text in the Authorized Redirect URIs box. (When using JavaScript, do not specify any redirects.)
  • In the Authorized JavaScript Origins box, type the protocol and domain for your site.
  • Make sure to enter the domain only, do not include any path value.
  • If your site supports both HTTP and HTTPS, you can enter multiple values, one per line.
  • Click the Create client ID button to complete the process.
  • The Create client ID dialog disappears. The Authorized API Access section now displays your application's OAuth 2.0 credentials.
  • Place these credentials in js/lib/auth_utils.js

Build Instructions

This project uses Grunt to automate build tasks.

  • Install Node.js
  • Install grunt-cli: npm install -g grunt-cli
  • Install dev dependencies: npm install
  • Run grunt to compile, or grunt server to start a live development environment.

Configurations

To pull a different set of data change these lines in js/main.js to whatever Dimensions and Metrics you wish to pull.

gapi.client.analytics.data.ga.get({
        'ids': 'ga:' + profileId,
        'start-date': lastNDays(30),
        'end-date': lastNDays(0),
        'metrics': 'ga:pageviews, ga:visits',
        'dimensions': 'ga:date',
        //'sort': '-ga:visits,ga:source',
        //'filters': 'ga:medium==organic',
        'max-results': 500
}).execute(handleCoreReportingResults);

Note

There are setTimeouts in js/main.js in the functions to pull from the API because I was getting Rate Limiting Errors. The loops I run through all the accounts, properties, and profiles was so freaking fast. So that's why those are there.

Analytics

About

Dumps google analytics data for all profiles, properties, and accounts into a csv using the javascript client library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published