Setting up Google Analytics integration
This tutorial will explain the process of leveraging data from Google Analytics 4 (GA4) in Ecommerce Search. After following this guide, you will know how to use GA4 metrics as commercial parameters.
Prerequisites
Before configuring the Ecommerce Search integration with GA4, a few things need to be in place:
- At least one segment within Ecommerce Search
- Access to the Ecommerce Search Courier API
- A valid GA4 property
- Google Analytics Data API must be enabled
- Credentials to a service account
Configuring Ecommerce Search
Configure the Ecommerce Search integration with GA4 requires the following steps:
- Connect a segment to a GA4 property with service account credentials
- Connect parameters to GA4 metrics
The integration to GA4 is configured through the Courier API.
Segment settings
Ecommerce Search must be provided with a property ID and corresponding service account credentials to access Google Analytics.
The credentials consist of a serviceAccountId
, which refers to the service account email, and a privateKey
, which can be obtained by following one of these guides.
Example
Adding service account credentials to a segment named b2b-dk-da
Warning
Please include the entire private key in the request without any modifications. The '\n' characters must be included.
Parameter settings
Once the GA4 credentials have been configured, Ecommerce Search can be configured to ingest commercial parameter values.
Example
Populating SKUs with a parameter, sales-7d
, containing the total number of purchases of that SKU in the last 7 days.
The dimension
and metric
are the GA4 dimension and metric to ingest. Please refer to the dimension and metric explorer for a list of valid dimensions and metrics. In the above example, the dimension itemId
is used to get the metric itemsPurchased
for each SKU.
The startDate
and endDate
fields determine the timespan of the data. In the example the range is from yesterday to 7 days ago, resulting in a weeks worth of data. See the official Google documentation of date ranges for more information.
Migrating from Universal Analytics
Warning
Previously configured Universal Analytics settings will still ingest data. Data ingested from Universal Analytics may conflict with data ingested from Google Analytics 4. This can be avoided by deleting old Universal Analytics settings.
Dimensions and metrics have new names in Google Analytics 4. A guide for converting Universal Analytics dimensions and metrics to Google Analytics 4 is available from Google. Note that dimensions and metrics with similar names may not share semantics. See API reference for detailed descriptions.