Set up Google Tag Manager to send data to Google Universal Analytics

This is for:

Developer
Important

Google Universal Analytics is subject to deprecation in 2023.

If you have implemented the Google Universal Analytics (Google UA) tag on your site via Google Tag Manager, you need to set up the trigger, variables, and a Google UA tag so that Coveo Experimentation Hub (CEH) can send the GTM event to Google UA.

Warning

CEH doesn’t send events to Google Universal Analytics (Google UA) and Google Analytics 4 (GA4) if any or both of the following are true:

  • the qb_dnt cookie is set to 1 or 2

  • the qb_dnt_ext cookie is set to ga

Note

When a visitor is served an experience, CEH sends a single custom event to Google UA and a single GTM event (for tags implemented via GTM).

CEH send these only once per session, when the visitor is served the experience.

Warning

These events are only sent for published experiences.

Set up the trigger

You need to create a trigger to detect when CEH sends the GTM event.

  1. Log in to your GTM account.

  2. From the left menu, select Triggers.

  3. Click the New button.

    The trigger card appears.

  4. At the top of the card, enter a trigger name.

  5. In the Trigger Configuration panel, click anywhere to open the Choose trigger type pane.

  6. Select Custom Event.

    The Trigger Configuration panel now shows trigger fields and settings.

  7. Specify the following:

    • In the Event name field, enter qubit.experience.

    • Select the Some Custom Events option.

    • Define the following trigger conditions: Event > equals > qubit.experience.

  8. Click the Save button.

Set up variables

Next, you need to create and set up variables for the experience ID and variation ID. GTM will send these variables to your Google UA tag.

  1. From the left menu, select Variables.

  2. In the User-Defined Variables section, click the New button.

    The variable card appears.

  3. Enter CEH experience ID as the variable name.

  4. In the Variable Configuration panel, click anywhere to open the Choose variable type pane.

  5. Select Data Layer Variable.

    The Variable Configuration panel now shows variable fields and settings.

  6. Specify the following:

    • In the Data Layer Variable Name, enter cehExperienceId.

    • In the Data Layer Version menu, select Version 2.

  7. Click the Save button.

You created a CEH Experience ID to store the experience ID.

Repeat these steps to create a variable for the variation ID, but use the following values for a new variable:

  • CEH variation main ID as the variable name.

  • cehVariationMainId as the Data Layer Variable Name.

Set up the Google UA tag

Now you need to create and configure the Google UA tag that will send the GTM event to Google UA when the trigger is activated.

  1. From the left menu, select Tags.

  2. Click the New button.

    The tag card appears.

  3. At the top of the card, enter a trigger name.

  4. In the Tag Configuration panel, click anywhere to open the Choose tag type pane.

  5. Select Google Analytics: Universal Analytics.

    The Tag Configuration panel now shows tag fields and settings.

  6. Specify the following:

    1. In the Track type menu, select Event.

    2. In the Category field, enter CEH Experience.

    3. In the Action field, click the button to the right and select the CEH experience ID variable.

    4. In the Label field, click the button to the right and select the CEH variation main ID variable.

    5. In the Value field, click the button to the right and select the CEH variation main ID variable.

    6. In the Non-Interaction Hit menu, select true.

    7. In the Google Analytics Settings menu, select the variable that you use to store your tracking ID from Google Analytics Settings.

      Tip

      If you haven’t already created a variable to store your tracking ID, you need to do it now.

      1. In the Google Analytics Settings menu, select New Variable to open the variable card.

      2. At the top of the card, enter a variable name.

      3. In the Tracking ID field, paste your tracking ID. If you don’t know your tracking ID, see Find your tracking ID and tracking code snippet.

        You can leave the other fields in their default state.

  7. In the Triggering panel, click anywhere to open the Choose a trigger pane.

  8. Select the trigger you created earlier.

  9. Click the Save button.