Setting up Google Tag Manager for Google Analytics 4

Google Tag Manager manages all your website tags. To integrate Commerce+ Transaction Server with Google Analytics, you must add tags for each store in the Google Tag Manager.

Google Tag Manager acts as a bridge between the Next.js 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 property.

Importing parameters for the Reference Store applications

For theReference Store applications, 2 sample Google Tag Manager containers are provided and pre-configured to route the events that are sent by the Next.js store to Google Tag Manager, to Google Analytics. The templates contain the configuration required for Google Analytics 4.

Complete the following steps to download the templates and import them into Google Tag Manager.
  1. Log into Google Tag Manager and go to the container for the Reference Store application.
  2. Go to the Admin tab and click Import Container.
  3. 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.
  4. Go to the Workspace tab > Variables.
  5. Find Measurement ID and update with the actual Google Analytics Measurement ID (For example, G-P0RKSXQB2D) from your data stream.
  6. Click Submit and then Publish to deploy this configuration on Google Tag Manager.