How can we help you?

Setting up Google Analytics with Google Tag Manager

This guide shows you how to track advisor interactions in both Google Analytics 4 and your bluebarry dashboard using Google Tag Manager (GTM).

💡 Important: While we’ll use GTM for tracking interactions, we recommend adding the main bluebarry script directly to your website, not through GTM.

Jump to a topic 👇🏻

Step 1: Create GTM Variables

First, create data layer variables in GTM.

Here’s how to create each variable:

  1. Go to “Variables” in your GTM dashboard
  2. Click “New” under “User-Defined Variables”
  3. Choose “Data Layer Variable” as the type
  4. Enter the variable name (e.g., “bluebarry_advisor_id”)

  5. Use the same name for “Data Layer Variable Name”

data-variable-settings

Repeat the steps for all the 9 variables below:

  • bluebarry_advisor_id
  • bluebarry_session_id
  • bluebarry_question_id
  • bluebarry_question_name
  • bluebarry_answer_id
  • bluebarry_answer_name
  • bluebarry_product_id
  • bluebarry_product_name
  • bluebarry_product_url

 

Your completed setup should look like this:

data-variables-setup

Step 2: Set Up GTM Triggers

Create triggers for each bluebarry event:

  • bluebarry_start_advisor
  • bluebarry_answer_submitted
  • bluebarry_question_viewed
  • bluebarry_result_viewed
  • bluebarry_result_opened

For each trigger:

  1. Click “Triggers” → “New”
  2. Name it “Event | [event_name]”
  3. Choose “Custom Event” as trigger type
  4. Enter the exact event name (e.g., “bluebarry_start_advisor”)

Below, you can find a screenshot of what your trigger setup should look like:

event trigger example

Step 3: Create GA4 Event Tags

Let’s create the GA4 event tags, starting with an example of how to set up bluebarry_answer_submitted:

  1. Go to “Tags” and click “New”. Name your tag “Event | bluebarry_start_advisor”
  2. For “Tag Configuration”: Choose “Google Analytics: GA4 Event”
  3. Enter your GA4 Measurement ID
  4. Set Event Name to “bluebarry_start_advisor”
  5. Click “Add Parameter”. Set the parameter name: “bluebarry_advisor_id”. For value: Choose the corresponding data variable. Repeat for “bluebarry_session_id”
  6. Under “Triggering”, select the matching trigger we created earlier
  7. Save your tag
event-bluebarry-gtm

💡 For each event’s parameters, use the matching variables we created in Step 1. The variable names and parameter names should be identical.

All GA4 events and corresponding event parameters:

bluebarry_start_advisor

  • bluebarry_advisor_id
  • bluebarry_session_id

 

bluebarry_answer_submitted

  • bluebarry_advisor_id
  • bluebarry_session_id
  • bluebarry_question_id
  • bluebarry_question_name
  • bluebarry_answer_id
  • bluebarry_answer_name

 

bluebarry_question_viewed

  • bluebarry_advisor_id
  • bluebarry_session_id
  • bluebarry_question_id
  • bluebarry_question_name

 

bluebarry_result_viewed

  • bluebarry_advisor_id
  • bluebarry_session_id

 

bluebarry_result_opened

  • bluebarry_advisor_id
  • bluebarry_session_id
  • bluebarry_product_id
  • bluebarry_product_name
  • bluebarry_product_url

Step 4: Create Custom Definitions in GA4

Every parameter that we’ve created in GTM, has to be added to GA4 as a custom definition as well.

  1. Navigate to Admin > Property settings > Data display > Custom definitions
  2. Click on “Create custom dimension”
  3. For every parameter the “Event parameter” has to have the exact same value the bluebarry parameter.
 
Your setup should look something like this:
ga4-custom-definitions

Step 5: Test Your Setup

To test your setup:

  1. Click “Preview” in GTM:
  2. Open your website
  3. Use your advisor from start to finish
  4. Also open the product results
  5. Check GTM’s preview mode to verify each event fires

Related articles

Need help?

Email us at support@bluebarry.ai!