๐ทGoogle Analytics 4 with GTM
Note: This is only needed if you have GA4 setup through GTM. If you have added the GA4 script tag directly in your HTML, the Optibase events will be sent automatically.
Guide: Setting Up a GTM Trigger for Optibase Variant Shown Event
This guide will walk you through setting up a Google Tag Manager (GTM) trigger that fires when an Optibase variant is shown. Additionally, we will create a tag that sends an event to Google Analytics 4 (GA4).
Step 1: Access GTM and Create a New Trigger
Log in to your GTM account and open the container you want to configure.
Navigate to Triggers in the left-hand menu.
Click on the New button to create a new trigger.
Name your trigger (e.g., "Optibase Variant Shown Trigger").
Choose Trigger Type: Custom Event.
Step 2: Set Up the Custom Event Trigger
In the Trigger Configuration, set the Event Name to a custom name, such as
optibase_variant_shown
.Choose This trigger fires on: All Custom Events.
Step 3: Create a Custom HTML Tag to Listen for Optibase Variants
Navigate to Tags in the left-hand menu.
Click on the New button to create a new tag.
Name your tag (e.g., "Optibase Variant Listener").
Choose Tag Type: Custom HTML.
Add the following HTML and JavaScript code to the HTML field:
Set the tag to fire on All Pages.
Step 4: Create Variables to Capture Event Data
Navigate to Variables in the left-hand menu.
Click on the New button to create a new variable.
Name your variable (e.g., "
event_category
").Choose Variable Type: Data Layer Variable.
Set the Data Layer Variable Name to
event_category
.Repeat steps 2-5 to create another variable for
event_label
.
Step 5: Create a GA4 Event Tag to Capture the Variant Data
Navigate to Tags in the left-hand menu.
Click on the New button to create a new tag.
Name your tag (e.g., "GA4 Optibase Variant Event").
Choose Tag Type: GA4 Event.
Select your GA4 configuration tag in the Configuration Tag field.
Set the Event Name to
optibase_variant_shown
.In the Event Parameters section, add the following parameters:
Parameter Name:
event_category
Value:
{{event_category}}
Parameter Name:
event_label
Value:
{{event_label}}
Click on Triggering and add the custom event trigger you created in Step 1 (e.g., "Optibase Variant Shown Trigger").
Step 6: Publish Your Changes
Click on the Submit button in the top right corner of the GTM interface.
Follow the prompts to publish your changes.
Final Check
Preview your GTM container to ensure that the custom event fires correctly when an Optibase variant is shown.
Check GA4 to verify that the events are being recorded as expected.
By following these steps, you will have set up a GTM trigger that listens for Optibase variant events and sends the relevant data to GA4.
Last updated