Install Google Tag Manager

  • Updated

As an 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. 

  1. Sign in to your GTM account.
  2. 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:

  1. Go to the Admin Console > Administration > Settings.
  2. Enter google track into the Search Box to see three settings under System Settings.

    googletrack_adminconsole.png

  3. Click System Settings.
  4. 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.
  5. 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

    AdditionalDomains_GTM.png

  6. Save your changes.

    GTM_Admin Console.png

Enable applicable settings in Google Analytics

To capture the data and the custom dimensions, you must enable both in the settings of Google Analytics.

Enable ecommerce

  1. Log in to the applicable Google Analytics view.
  2. Go to Admin.
  3. Turn on the Status slider under Ecommerce SettingsEnable Ecommerce.
  4. Leave the remaining fields off (optional).
  5. Repeat this process for all views you wish to capture data.

Enable custom dimensions

  1. Go to Property Settings > Custom Definitions > Create Custom Dimensions in Google Analytics.
  2. Add the following custom dimensions:
    1. Authentication State – Set the Scope to Hit.
    2. User ID – Set the Scope to Hit.
    3. Session ID – Set the Scope to Session.
    4. item_ID – Set the Scope to Item.
    5. 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.

  1. Go to the View Settings for the Google Analytics view you are using with Configured Commerce.
  2. Turn on Site Search Tracking.
  3. Enter criteria as the Query Parameter.
  4. Save your changes.
  5. Repeat this process for all views you wish to capture Site Search data.

mceclip1.png

Import new tags

  1. Sign in to your Google Tag Manager account.
  2. Click Admin in the top menu.
  3. Go to Container > Import Container. Import the ga4-container-purchase.json file at the bottom of the article.
  4. Select Existing workspace > Default Workspace.
  5. Select Merge and Rename conflicting tags, triggers, and variables. Click Confirm.
  6. Click Tags in the left menu.
  7. 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.

  8. Click Submit.
  9. Put today's date under Version Name so you can track when these changes were published.
  10. 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

mceclip2.png

Variable - User ID

mceclip3.png

Variable - Session ID

mceclip4.png

Variable - Measurement ID

Replace the Tracking ID with your own Measurement ID in the Google Analytics Admin page.

mceclip5.png

Trigger - virtualPageview

mceclip6.png

Trigger - eCommerce Transaction Event

mceclip7.png

Tag - Google Analytics eCommerce

Replace the Google Analytics Settings in the GA ID variable as listed below.

mceclip9.png