Google Analytics Connector CLI Setup Guide
Steps to add this connector to your installation
The steps to launch your connector are:
- Generate Google API keys
- Specify the connector config
- Add the Google Analytics connector
1. Generate Google API keys
Setup requirements
Before getting started please make sure to have the following information:
- Access to an active Google account
Setup instructions
Get Google Analytics OAuth credentials
Log into Google Developer Console for your account and select (or create) project https://console.developers.google.com/apis/api/analyticsreporting.googleapis.com/overview
Click on Credentials to create OAUTH2 Client Ids.
Click on the created client id to store it in a json file.
Use the client_id obtained in step 3 in the following url and go to this url in a browser(safari is better with error messages):
You will be prompted to log in with your google credentials and also prompted to allow access to Google access the url with your credentials
You will then be redirected to with a page like this:
Save the code parameter. The code can be redeemed only once. If it is already redeemed, it will throw an error and step 4 needs to be repeated to get a valid code.
- Now, run the following command using a terminal:
The response will be like:
You will need to use client id, client secret, access token and refresh token.
Provide View Id of the project
In Google Analytics web console
Click Admin > View > View Settings > Id
This
Id
needs to be saved in the runtimeConfig file asview_id
.
2. Specify the connector config
To get a template for the Google Analytics connector configuration save the output of the describe --input-parameters
command as follows:
Necessary input parameters:
view_id
- The Consumer Key from the connected app definition.client_id
- OAuth client idclient_secret
- OAuth client secretaccess_token
- OAuth access tokenrefresh_token
- OAuth refresh tokenloadunits
- for each load unit you can specify the following parameters: ( Please refer to https://developers.google.com/analytics/devguides/reporting/core/dimsmets to get the list of load units and the supported metrics and dimensions for each load unit )metrics
- The list of metrics to be fetched for the load unit.dimensions
- The list of dimensions to be fetched for the load unit.
Optional input parameters:
for datasource:
schedule
- in cron format
for loadunit:
schedule
- cron format. You can define a different schedule for the table from the global schedule set above.filters
: dimensions filtersExample templates:
3. Add the connector
connector-name
Name of your connector. A schema with your connector-name is automatically created in your warehouseparams-file
File path to your input parameters file. Ex. googleanalytics_parameters_file.json
Got questions? Interested?
Please contact Datacoral's Support Team, we'd be more than happy to answer any of your questions.