A bouzuya/cars counter for the Google Analytics tag in blog.bouzuya.net
$ npm install --save bouzuya/cars-counter-bbn-google-analytics
- Create a "service account key"
https://console.developers.google.com/apis/credentials
New credentials > Service account key > Create (key type: JSON)
- Add client_email to Google Analytics settings
Copy "client_email" value in created json file.
Add "Read & Analyze" permission to your ”client_email".
Admin > VIEW > User Management > Add permission for ... > Input client_email and select "Read & Analyze".
- Set environment variables
$ export GOOGLE_ANALYTICS_VIEW_ID='...' # e.g. '99999999'
$ export GOOGLE_ANALYTICS_CLIENT_EMAIL='...' # e.g. '[email protected]'
$ export GOOGLE_ANALYTICS_PRIVATE_KEY='...' # e.g. '"-----BEGIN PRIVATE KEY-----\n..."'