In this article, we'll describe how to create a service account in Google APIs console and how to connect Google Analytics as data source using this service account.
Step 1: Create API Project and Add Service Account
- Go to Google APIs and create a new project if necessary.
- Switch on Google Analytics API by clicking on '+ Enable APIs and Services', searching for 'Google Analytics API', and clicking 'Enable'.
- Go to Project settings (icon with three dots in the upper right corner) → Service Accounts, click '+Create a Service Account', fill in the required information, and click 'Create'.
- On the 'Service account permissions' step, select Role - Editor and click 'Continue'.
- You'll be redirected to a page with the account's information and the option to create a key. Click '+Create key, select key type - P12, click 'Create', and save the file. Click 'Done'. A new page with your account information will be displayed - please don't close the tab for the time being, you'll need it on the next step!
The service account you've created will also be displayed in the Credentials section of your console will all the information you may need for future reference.
Step 2: Add Google Analytics Data Source to Data Virtuality Studio
In Data Virtuality Studio, click 'Add Data Source' and select 'Google Analytics' from the list. Enter the required information as shown below:
- Alias - e.g. GoogleAnalytics (please keep in mind that the alias may contain only Latin letters, digits, and underscores);
- Client email - your service account's email (if you've closed the tab with this information, you can look it up in the Credentials section under Service Accounts);
- Key file path locally - location of your downloaded P12 file. Alternatively, you can generate base64 representation of your key file and enter it in the 'Key Base64 encoded' field;
- Data source parameters - importer.useFullSchemaName=false (default value).
Click 'Next' and then 'Finish', and you're settled!
If It Doesn't Work...
If after clicking the 'Finish' button you're getting the 'Invalid grant' error message, please check the following:
- Your service account has the correct role ('Editor' or 'Owner');
- You have created the service account under the same Google account you use for Google Analytics;
- the local time is in sync with the server time (maximum admissible difference is 5 minutes).
Please sign in to leave a comment.