Setting up Google Tag Manager for Google Analytics 4
Google Tag Manager manages all your website tags. To integrate HCL Commerce with Google Analytics, you must add tags for each store in the Google Tag Manager.
Google Tag Manager acts as a bridge between the React Store and Google Analytics.
- For each GA4 event, a trigger and GA4 event are defined.
- For each GA4 event, a Measurement ID must be specified. We use a variable to set this.
Prerequisites
You must have a Google Tag Manager account.
Note: These steps are provided for you to set up a Google Analytics 4 property
alongside your existing Universal Analytics property.
Importing parameters for the Reference Store applications
For the Emerald and Sapphire Reference Store applications, 2 sample Google Tag Manager containers are provided and pre-configured to route the events that are sent by the React store to Google Tag Manager, to Google Analytics. The templates contain the configuration required for both Universal Analytics, and Google Analytics 4.
Complete the following steps to download the templates and import them into Google
Tag Manager.
- Download IMPORT-GTM-CONTAINER_EmeraldWorkspace.json and IMPORT-GTM-CONTAINER_SapphireWorkspace.json.
- From version 9.1.12 onwards, download IMPORT-GTM-CONTAINER_Emerald and EmeraldMP Workspace and IMPORT-GTM-CONTAINER_Sapphire and SapphireMP Workspace.
- From version 9.1.13 onwards, download IMPORT-GTM-CONTAINER_Emerald and EmeraldMP Workspace and IMPORT-GTM-CONTAINER_Sapphire and SapphireMP Workspace.
- From version 9.1.14 onwards:
- For the Emerald and Sapphire store continue using the version from 9.1.13, it is unchanged.
- For the Ruby and RubyB2B store, use GTM-9.1.14-RubyB2B and GTM-9.1.14-RubyB2C.
- From version 9.1.16 onwards:
- For the Emerald store, use GTM-9.1.16-Emerald.
- For the Sapphire store, use GTM-9.1.16-Sapphire.
- For the RubyB2C store, use GTM-9.1.16-RubyB2C.
- For the RubyB2B store, use GTM-9.1.16-RubyB2B.
- Log into Google Tag Manager and go to the container for the Emerald Reference Store application.
- Go to the Admin tab and click Import Container.
- Upload the template json files into the container. Select Existing workspace > Default workspace and select the Merge option with Overwrite conflicting tags, triggers and variables.
- Go to the Workspace tab > Variables.
- Find Measurement ID and update with the actual Google Analytics Measurement ID (For example, G-P0RKSXQB2D) from your data stream.
- Click Submit and then Publish to deploy this configuration on Google Tag Manager.
Note: After upgrading from one version to another version
of HCL Commerce, the specified JSON file should also be changed. For
example, if you are upgrading from HCL Commerce version 9.1.11 to
9.1.14, then the JSON files should be replaced with the files suggested in Step 4.