Adding a Google Analytics credential to Civis must be done by someone with Manage Users and Edit permissions on the relevant Google Analytics account.
- Select a project and enable the Analytics API.
- Go to https://console.developers.google.com/flows/enableapi?apiid=analytics&credential=client_key
- If you have an existing project you know you want to use, choose that project from the dropdown and go through the steps to enable the API. If you don't have an existing project, or don't know what one is, create a new one; the API should be automatically enabled in the process.
- Create a service account
- Which API are you using? - Analytics API
- Where will you be calling the API from? - Other non-UI (e.g. cron job, daemon)
- What will you be accessing? - Application data
- Are you using Google App Engine or Google Compute Engine? - No, I'm not using them.
- Click the Go to Credentials button that should appear after the previous step. Or go to https://console.developers.google.com/apis/credentials/wizard.
- Fill out the form with these options
- Click "What credentials do I need?"
- Create your service account. Give it a name that will help you remember it, and choose a JSON key.
- Click "Continue".
- Your key file should download. This is the only copy, so make sure to store it securely.
- Authorize the service account on the relevant Google Analytics account.
- Sign in to your analytics account.
- Select the Admin tab, and then navigate to the view for which you wish to retrieve Analytics data. If there are multiple such views, repeat these steps for all of them.
- Click User Management in the desired view's column.
- Under Add Permissions For, enter the service account's email address. You can find it in the service_account field in your key file.
- Select permissions at the Collaborate level.
- Click Add.
- Make any Custom Segment for which you want data available to the service account.
- Sign in to your analytics account.
- Select the Admin tab, and then navigate to the view in which the segment lives. If there are multiple such segments, repeat these steps for all of them.
- Click Segments in the desired view's column, then click the appropriate segment,
- In the upper right corner is some small print giving the segment's current visibility. Click the small "Change" link right after that text.
- Select "Collaborators and I can apply/edit Segment in this view", and save.
- Note: you will also need the ID for each Custom Segment when you use the Civis custom script. These can be found using the API Explorer at https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/segments/list#try-it. Leave fields blank, just click Authorize and Execute, grant the permissions, and search for your segment from the resulting list.
- Create a credential in Civis using your new key.
- From the top navigation menu, select Data, and then under Imports, click on Google Analytics.
- Click on "Add Credential" just below the "Google Analytics Credential" field.
- Fill out the form as follows:
- Name - Name it something that will make sense to you.
- Credential Type - Custom
- Username - Put the contents of the client_email field in your keyfile. Don't include the enclosing quotes.
- Password Type - Multiple lines
- Password - Put the contents of the private_key field in your keyfile. Make sure to include the "-------BEGIN PRIVATE KEY-------" and "-------END PRIVATE KEY-------" lines. Don't include the enclosing quotes.
- Click Save
Comments
0 comments
Article is closed for comments.