HCL Commerce Version 9.1.4.0 or later

Configuring the Transaction server

To complete the integration between a React Store and Google Tag Manager, you must add the required parameters to the Transaction server.

Obtaining the Google Tag Manager container parameters

  1. Go to Google Tag Manager.
  2. Select the container and go to Admin tab > Environments.
  3. Click Actions > Get Snippet for live option.
  4. Copy the gtm_auth and gtm_preview values.

UA Configuration

Sample curl commands to add new configurations for the Transaction server.
curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.analytics.versions","value": "UA"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.analytics.service.account.view.id","value": "<YOUR VIEW ID FROM THE GOOGLE ANALYTICS STORE PROPERTY>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.container.id","value": "<YOUR STORE CONTAINER ID FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.auth","value": "<YOUR STORE AUTH VALUE FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.preview","value": "<YOUR STORE PREVIEW VALUE FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'
Sample SQL statements to configure the Transaction server
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.analytics.versions', 'UA', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.container.id', '<GTM_Container_ID>', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.auth', '<GTM_AUTH_ID>', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.preview', 'env-1', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.analytics.service.account.view.id', '<View_ID>', 0);
Note: Google support for the Universal Analytics will not be available from July 2024.

GA4 Configurations

Sample curl commands to add new configurations for the Transaction server.
curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.analytics.versions","value": "GA4"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.container.id","value": "<YOUR STORE CONTAINER ID FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.auth","value": "<YOUR STORE AUTH VALUE FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.tag.manager.preview","value": "<YOUR STORE PREVIEW VALUE FROM THE GOOGLE TAG MANAGER CONFIGURATION>"}'

curl -k -u `spiuser:plain_text_spiuserPassword` --location 'https://<transaction_server_ip>:<port>/rest/admin/v2/store-configurations?storeId=<STOREENT_ID>' --header 'Content-Type: application/json' --data '{"storeId":<STOREENT_ID>,"name": "google.analytics.property.ga4,"value": "<YOUR GA4 PROPERTY ID FROM THE GOOGLE ANALYTICS ACCOUNT>"}'
Sample SQL statements to configure the Transaction server
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.analytics.versions', 'GA4', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.container.id', '<GTM_Container_ID>', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.auth', '<GTM_AUTH_ID>', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.tag.manager.preview', 'env-1', 0);   
INSERT INTO STORECONF (STOREENT_ID, NAME, VALUE, OPTCOUNTER) VALUES (<StoreId>, 'google.analytics.property.ga4', 'GA4_Property_ID', 0); 

Database configurations for Management Center to connect to Google Analytics

Table 1. Sample data
Configuration Table in Database Parameter name Description and Value
Service account: Allowed scopes.

Used by the Transaction server to generate an access token.

STORECONF google.analytics.service.account.scopes The OAuth allowed scopes that this Google Service Account is allowed to access.

https://developers.google.com/identity/protocols/oauth2/scopes#analyticsreporting

www.googleapis.com/auth/analytics.readonly

OAuth Client ID

Used by Management Center to connect to Google Analytics

STORECONF google.analytics.client.id The OAuth client ID configured through the Google API console.

This is required for HCL Commerce to authenticate with Google and authorize with Google Analytics.

Service Account - View ID STORECONF google.analytics.service.account.view.id Your service account view ID.

The property ID for the GA4 account

STORECONF google.analytics.property.ga4 Your store property ID for the GA4 account.

Database configuration for store to connect to Google Tag Manager

Table 2. Sample data
Table in Database STOREENT_ID Parameter name Value
STORECONF Enter your STOREENT_ID google.tag.manager.container.id Your store Container ID from the Google Tag Manager configuration.
STORECONF Enter your STOREENT_ID google.tag.manager.auth Your store Auth value from the Google Tag Manager configuration.
STORECONF Enter your STOREENT_ID google.tag.manager.preview Your store preview value from the Google Tag Manager configuration.