git clone https://github.com/janpapenbrock/realtime.git
/path/to/realtime $ npm install
- Create a project in Google Developers Console
- At
APIs
, enableAnalytics API
- Create an OAuth client ID,
Service Account
type - Note the mail address associated with it somewhere
- Download the created file named
YOURPROJECTNAME-<hash>.p12
- Convert this file into
key-pem
with
openssl pkcs12 -in YOURPROJECTNAME-<hash>.p12 -out key.pem -nocerts -nodes -passin pass:notasecret
- Put
key.pem
intorealtime/config/
- Open Google Analytics
- Navigate to
Admin
and choose your account on the left - Open
User Management
- At
Add permissions for:
, enter the mail address associated to your API client ID (<long-string>@developer.gserviceaccount.com
).Read and Analyze
setting is sufficent.
- Copy
realtime/config/google.json.sample
torealtime/config/google.json
- Open
realtime/config/google.json
in your favorite editor - Set the mail address once again:
"email": "<long-string>@developer.gserviceaccount.com",
- Analytics accounts are structured on three levels: Accounts, Properties and Views.
- Realtime allows to add all Accounts which should be considered for the dashboard
"account": {
"include": [ "1234567", "2345678" ]
},
- To avoid multiple views of the same website show up, filtering on both Property and View level is possible:
"webProperty": {
"exclude": [ "UA-123456789-1" ]
},
"profile": {
"exclude": [ "9876543210" ]
}
When you are all set up, in a terminal, run
/path/to/realtime $ node index.js
Then open up Chrome and visit http://localhost:8888
The result of all this hard work should be something like this: