Overview
Google Analytics is a service that tracks and reports website traffic. It is part of the Google Marketing Platform. This integration provides you with the most important information to better understand and manage your customer behavior in a user-friendly format.
Setup
This integration uses a service account to access the Google Analytics Reporting API.
During initial setup, Two Circles will pull 12 months of historical data. (More can be pulled upon request.) Afterward, the integration performs an incremental pull each day. The incremental pull captures data from the past 30 days to ensure none is missed if the integration fails for any reason.
Please follow the below steps to have the Google Analytics service enabled
-
Client:
-
Sign-in to Google using a Google Account that has owner or admin rights for your Analytics account. (Specifically, you must have the iam.serviceAccountAdmin role.)
-
The steps are defined below to know/create/enable -
-
Google Cloud Project Name
-
Service Account for Two Circles
-
Google Analytics Data API service
-
JSON file containing credentials
-
Email Address of Service Account
-
Google Analytics Property
-
Addition of the user [Two Circles service account’s email address] to the Google Analytics Property
-
-
Find Google Cloud Project name and service account detail that has been already created for Two Circles.
-
You can skip this section and move to “Add the service account email address to the property" section, if following checklist are already known or completed
-
Google Cloud Project
-
Service Account created for Two Circles under this project with Basic Viewer role
-
Downloaded the JSON file containing credentials of this service account
-
-
To know the project name, service account and download JSON file, open this - https://console.cloud.google.com/welcome
-
Click on “Project drop down” [top - center]
-
Click on “All” to see all projects that have been created in the past -
If no projects are visible then Create Google Cloud Project section in this guide.
-
Else, select a project and search Service Accounts from the search box and select the same.
-
Check if any service account is visible in the list of service accounts containing “Two Circles” in its email address.
-
If Two Circles service account is not found in any of the project then to create a Two Circles specific service account, either you can utilize one of the existing project or create a new one.
-
If you are planning to utilize existing project then follow Create service account section of the user guide.
-
If you are planning to create new project then follow Create Google Cloud Project section of the user guide.
-
- Else, If found, keep a note of this Two Circles service account
-
On the left hand panel, Click on IAM
-
Then click on View by Roles. If above service account is listed in viewer role then you can jump to Create and download JSON file section of the user guide.
-
If above Two Circles service account is not visible in viewer role then click on Grant Access. On the right side panel, under the Add Principals, Type Two Circles and select the service account.
-
Under Under the Assign roles and “select a role” drop down, Select basic viewer role.
-
Click Save
-
Note down this project name and service account name.
-
Navigate to Create and download JSON file section.
Create Google Cloud Project (If not available)
-
Follow this step - https://developers.google.com/workspace/guides/create-project
-
Enable the IAM API - https://console.cloud.google.com/flows/enableapi?apiid=iam.googleapis.com
-
Make sure that you can see the recently created project in top banner new search box.
-
Click Next
-
Click Enable.
-
Move to next section to create new service account
Create a new service account for Two Circles. (Skip if you already have service account for Two Circles)
-
Create a new service account for KORE. (Skip if you already have service account for KORE)
a. Set the service account's name to "KORE Google Analytics Integration".
b.
Click on CREATE AND CONTINUE
c.
Click in “Select a role” drop down
d.
Click on Basic and Viewer
e. Click to Continue
f.
Click on Done -
Now you have created project and service account for Kore with Basic viewer role. -
Next step is to create and download JSON file
Create and download JSON file
-
In the search box, search and open Service Accounts
-
From the list of service accounts, select the one created for Two Circles.
-
Click on Keys in top panel
-
Click on Add Key and select Create new key
-
Keep JSON selected and click Create. A JSON file will get automatically created and downloaded (you may get prompt to define the download location of the file).
-
Click Close.
-
Keep this file handy and safe. You will need to provide this file to Two Circles after following below steps.
-
Open this file in notepad and find “client_email” and the email address present in it.
-
Keep it handy as you will required this email address to be added to Google Analytics property in next sections.
Enable Google Analytics Data API Service
-
Go to https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries
-
Click on “Enable the Google Analytics Data API v1”.
-
In the popped up window, click ”BACK”.
-
In the next window, use dropdown to select the project [as identified from the above sections] that contained the service account created for Two Circles.
- Click Next.
-
You will see a similar window -
-
Click on DONE. -
Move to next section to add service account email address to the property id.
Add the service account email address to the property
-
It is assumed that on the Google Analytics portal, you have already created a single GA4 property that is already capturing analytics data of the your organization’s required website.
-
If you have multiple websites, you can create one GA4 property for each website.
-
It is also assumed that you have the email address of Two Circles service account handy.
-
Go to admin section of the Google Analytics portal,
-
Click the desired Account and the property. And, then click Property Access Management.
-
From the right side, a sliding panel will appear, click on plus sign on right top corner (+). It is meant for adding user to the property.
-
Click "Add Users"
-
Paste the Two Circles service account email address.
-
In the roles section, choose "Viewer"
-
Click on "Add" present on right top corner.
-
-
Note down this property ID. You will need to share this with Two Circles. If you have created multiple ga4 properties, then repeat the same process of adding the email address of the service account across all properties. One property will result into one schema object on your Two Circles DWA instance.
-
Please refer below section.
Provide Two Circles with the below information required for source connectivity
-
-
JSON file containing credential. It will contain below attributes -
-
type
-
project_id
-
private_key_id
-
private_key
-
client_email
-
client_id
-
auth_uri
-
token_uri
-
auth_provider_x509_cert_url
-
client_x509_cert_url
-
-
Property ID(s)
-
If you are providing multiple property ids, then provide a short friendly name of each of the property as well, so that same can be suffixed in the schema name to differentiate between data of different properties.
-
-
Ask your Two Circles Success Manager for a secure location to upload the JSON file. (Alternatively, you can encrypt the file with a password and email it. Then use our secure information portal to provide the password.)
-
Data dictionary and table descriptions
Note: No ERD is provided because the tables in this schema do not have any relationships to each other.
Table Description
page_tracking
Returns metrics page views related to page title and actual link of the page.
advertising_traffic_sources
Contains information of sessionCampaignName, sessionDefaultChannelGroup, metrics of a advertiserAdClicks, sessions, costs, number the users, avg duration, page views.
adwords_metrics
Contains adwords metrics such as advertiserAdCostPerClick, advertiserAdClicks and adveristerAdCost.
audience_demo
Returns detailed information of audiences such as user age range, gender, number of users, sessions, avg session duration, page views, and transaction revenue.
audience_interest_market
Contains brandingInterest categories and number of visits by date.
channel_grouping
Returns channel-group categories by users, sessions, avg session duration, page views, and transaction revenue.
device_type
Shows details about end-users device type such as browser, data source, number of users, sessions, avg session duration, page view, and device category.
ecommerce_product_purchase_value
Returns details about e-commerce products, brands, revenue per item, quantity, and unique purchases.
event_tracking
Contains detailed information related to events such as event category, event label, total events, sessions, and transactions.
geo_network
Returns geolocation such as latitude and longitude and details of the number of users, sessions, location details(metro), region, revenue, and number of transactions by date.
marketing_attribution
Returns marketing information related to campaigns, ad contents, source as well as number of clicks, transaction revenue and number of transactions.
time
Returns metrics such as users, sessions, average session duration, page views, by date, hour, days of the week.
topline
Contains information related to number of users, new users, sessions per users, sessions, bounces, bounce rate, hits by date.
traffic_sources
Returns details of the traffic including information such as source, medium, platform, number of organic searches, sessions, number of users, page views.
page_tracking_traffic_source
Returns pageviews for distinct combinations of date, page (URL), and source / medium.
page_conversion_rates
Object returns the page details with revenues,transactions and page views.
Example queries
Show the top 25 metro areas your site visitors come from in the past week:
SELECT metro, SUM(CAST(users AS INT)) AS visitors
FROM google_analytics.geo_network
WHERE "date" > DATEADD(WEEK, -1, CURRENT_DATE)
AND metro NOT LIKE '(not set)'
GROUP BY metro
ORDER BY visitors DESC
LIMIT 25;
Show the top 25 traffic sources your visitors came from in the past week, distinguishing organic links from referrals:
SELECT medium, "source", SUM(users) AS total_users
FROM google_analytics.marketing_attribution ma
WHERE "date" > DATEADD(WEEK, -1, CURRENT_DATE)
GROUP BY medium, "source"
ORDER BY total_users DESC
LIMIT 25;