Google Analytics integration

This article describes how to configure GA4 to track group assignments using Google Tag Manager (GTM). This integration enables group assignment tracking that distinguishes users into a test group (those shown a message) or control group (those not shown a message). This data feeds into your analytics platform to help you monitor performance and understand how your traffic is being split. 

The main steps to set up Google Analytics (GA4) include:

  1. Add the group assignment snippet to your site header
  2. Configure Google Analytics (GA4) to capture and store group assignment events
  3. Grant Bazaarvoice contributor permissions

Step 1: Add the group assignment snippet

The group assignment snippet determines which users belong to the "Test" or "Control" group and will send the group assignment to your analytics with every page load and session start. This data forms the foundation Contextual Commerce uses to measure impact and ensure ongoing data alignment. 

Add the following granifyEventGroupAssigned  JavaScript snippet to your site header or tag manager:

Note: This group assignment snippet should be placed in your site header or tag manager so that it is called before the BV loader or Contextual Commerce snippet.

Step 2: Configure Google Analytics (GA4) using Google Tag Manager (GTM)

This section explains how to set up Google Analytics to ingest and store the group assignment data. Steps involve defining variables, triggers, and custom dimensions to track the group assignments for each user session.

Set up a new variable for the Test group

Create a variable in GTM that captures the group assignment data sent from the JavaScript snippet. The variable will make group assignments accessible for use in other configurations, such as event tracking. This step ensures that the group assignment event is captured and stored as a variable for use in GTM.

  1. In Google Tag Manager (GTM), navigate to the Variables section.
  2. Select New to create a new variable configuration.
  3. Choose the JavaScript Variable option.
  4. Name the variable granifyGroup.
  5. This variable will pull the gfy.groupAssigned event from the JavaScript function implemented on your website.
GTM Variable Configuration for JavaScript Variable granifyGroup using global variable gfy.groupAssigned.

Add a new trigger in GTM

Create a trigger ensures that the gfy.groupAssigned event will send the data to GA4 every time it occurs.

  1. Go to the Triggers section in GTM.
  2. Click New to create a new trigger.
  3. Choose the Custom event trigger type.
  4. In the Event name field, enter gfy.groupAssigned.
  5. Set the trigger to fire on All Custom Events
  6. Save the trigger.
GTM Trigger Configuration for a Custom Event named gfy.groupAssigned set to fire on all custom events.

Setup a new user and event custom dimension

Set up a custom dimension to allow GA4 to track the group assignment as part of both user data and event data, improving reporting and analysis.

  1. Open Google Analytics and go to Data display > Custom definitions.
  2. Select Create Custom Dimension.
  3. Create two new custom dimensions:
    • User Dimension: Name it granifyGroup.
    • Event Dimension: Name it granifyGroup.
  4. Set the Scope to User or Event, based on the type of dimension you're creating.

  5. Save the custom dimensions.

GA4 Custom definitions table listing granifyGroup as both an Event and User scoped dimension.

Send  data to GA4 

Create a tag to ensure group assignment data flows into GA4. This tag will fire the event and store the group assignment details each time it occurs.

  1. In GTM, navigate to the Tags section.
  2. Create a new GA4 Event Tag.
  3. In the Tag Configuration, enter gfy.groupAssigned as the event name.
  4. Under Event Parameters, add the following parameter:
    • Name: granifyGroup
    • Value: Select the Granify Group variable you created earlier.
  5. Add the trigger you created to this tag.

  6. Save the tag and publish your changes in GTM.

GTM GA4 Event Tag configuration for gfy.groupAssigned mapping the granifyGroup variable to event parameters and user properties.

Step 3: Share analytics permissions

Bazaarvoice needs analyst access to validate and maintain Contextual Commerce  and Google Analytics data  alignment. 

This role enables Bazaarvoice to:

  • Monitor the Contextual Commerce integration between your site and GA4 for data accuracy.
  • Assist in building and maintaining dashboards as your site evolves.
  • Provide insights and make recommendations to improve data usage.

Follow this GA help guide and set the account to the “Analyst” role for instructions on how to provide analyst access to analytics@granify.com.

Provide feedback button