As a Optimizely Configured Commerce user, you can install Google Analytics 4 or a Google Tag Manager container on your various websites and domains. Follow the steps below to implement Google Tag Manager.
You need the ISC_Implementer role to make these changes.
Locate the Google Tag Manager Container ID
Find the unique Google Tag Manager Container ID (GTM ID) and the domains in which you want that tracker installed. Configured Commerce then places the Google Tag Manager snippet with your provided GTM ID in the correct locations on your site and installs the data layer for future use.
- Sign in to your GTM account.
- Expand All accounts and select the appropriate container. The container ID displays at the top of the page.
Update the Google Tracking Settings
Google Analytics requires you to configure three settings:
- Google Tracked Domains – A list of domain names that have Google Tracking enabled for B2B Analytics. Include the fully qualified domain, which is anything between the https:// and the next /. For example, www.mydomain.com.
- Google Tracking Account ID – The GTM ID of the container you want to install.
- Google Tracking Type – The tracker you have decided to use. Options: GoogleTagManager or Google Analytics 4
For Spire sites, be sure to add the domain name (non-url) to the GTM settings.
Follow these steps to update the settings in Configured Commerce:
- Go to the Admin Console > Administration > Settings.
- Enter google track into the Search Box to see three settings under System Settings.
- Click System Settings.
- Set the following options under Analytics:
- Google Tracking Type – Select Google Tag Manager.
- Google Tracked Domains – Enter the website URL as defined on the websites page for that specific site.
- Click Add More to add additional domains (for Spire clients to set 2 entries for tracked domains).
- The customer facing URL (not the integration URL)
- The commerce “website name” (See example below)
- The GTM Tracking ID from Google Tag Manager
- Save your changes.
Enable applicable settings in Google Analytics
To capture the data and the custom dimensions, you must enable both in the settings of Google Analytics.
- Log in to the applicable Google Analytics view.
- Go to Admin.
- Turn on the Status slider under Ecommerce Settings > Enable Ecommerce.
- Leave the remaining fields off (optional).
- Repeat this process for all views you wish to capture data.
Enable custom dimensions
- Go to Property Settings > Custom Definitions > Create Custom Dimensions in Google Analytics.
- Add the following custom dimensions:
- Authentication State – Set the Scope to Hit.
- User ID – Set the Scope to Hit.
- Session ID – Set the Scope to Session.
- item_ID – Set the Scope to Item.
- item_name – Set the Scope to Item.
The custom dimension Index number should match how they are configured on your Google Analytics tag inside Google Tag Manager.
Enable Site Search Tracking in Google Analytics (optional)
You may also enable Site Search Tracking in Google Analytics to understand visitor engagement metrics for the search box on your site. This setting captures metrics such as percentage of sessions with search and all keywords that have been searched.
- Go to the View Settings for the Google Analytics view you are using with Configured Commerce.
- Turn on Site Search Tracking.
- Enter criteria as the Query Parameter.
- Save your changes.
- Repeat this process for all views you wish to capture Site Search data.
Import new tags
- Sign in to your Google Tag Manager account.
- Click Admin in the top menu.
- Go to Container > Import Container. Import the ga4-container-purchase.json file at the bottom of the article.
- Select Existing workspace > Default Workspace.
- Select Merge and Rename conflicting tags, triggers, and variables. Click Confirm.
- Click Tags in the left menu.
- Click on the GA4 - Purchase tag. Ensure that the Measurement ID matches your Google Analytics account. If not, click the Edit icon, and update the Measurement ID. Click Save.
If you do not know how to get the Measurement ID, see Install Google Analytics 4.
- Click Submit.
- Put today's date under Version Name so you can track when these changes were published.
- Click Publish.
Configure tags, triggers, and variables in Google Tag Manager
You can configure the tags, triggers, and variables Configured Commerce uses in Google Tag Manager.
Variable - Authentication State
Variable - User ID
Variable - Session ID
Variable - Measurement ID
Replace the Tracking ID with your own Measurement ID in the Google Analytics Admin page.
Trigger - virtualPageview
Trigger - eCommerce Transaction Event
Tag - Google Analytics eCommerce
Replace the Google Analytics Settings in the GA ID variable as listed below.