ga
Google Analytics via the Command Line
THIS IS A WORK IN PROGRESS, CURRENTLY AUTH IS WORKING
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 APIS & AUTH > APIs from the side 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). NOTE: google autmoatically will have other services turned on you can switch those off as long as you keep Google Analytics 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 APIS & AUTH > Credentials in the side menu.
- The API Access pane appears.
- Click Create an OAuth 2.0 Client ID.
- The Create Client ID dialog appears.
- Click the Installed Application radio button and Other. It should look like below:
- Click Create.
- The credentials under Client ID for native application can be used when prompted by
ga --configure
Installation
Via Go
$ go get github.com/jfrazelle/ga
Binaries
Usage
Global Options
--disable-plot
: Disable plotting--clientid, -c
: Google OAuth Client Id, overrides the .ga-cli files--secret, -s
: Google OAuth Client Secret, overrides the .ga-cli files--debug, -d
: Debug mode--json
: Print raw json--raw
: Don't colorize output
accounts
Get accounts
configure, config
Configure your Google API Credentials
now
Get Realtime Data, dimensions and data reference available at https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/
--profile, p
: Profile id for which to get data--metrics, -m
: Real time metrics to get. default:'rt:activeUsers'
--dimensions, --dim
: Real time dimensions (comma-separated). ex:'rt:pagePath,rt:pageTitle'
--sort
: Sort to apply
profiles
Get profiles
--account
: Account id for which to list profiles
properties
Get profiles
--account
: Account id for which to list properties
help, h
Shows a list of commands or help for one command