Tracking with Google Tag Manager

Google Analytics 4 events tracking integration with Google Tag Manager (GTM)

In this documentation we show an example of how to connect the search events to an analytics account via GTM.

After this configuration you can follow the steps in the Google Site Tag Events Tracking documentation to configure the events.

Configuring Variables

There are 4 Data Layer variables, which has to be added:

  • event_category

  • event_label

  • event_name

  • event_value

To add the variables, open up your Google Tag Manager account, click on Workspace and Variables menu. Under the User-Defined Variables table click the New button.

Choose Data Layer Variable for the type and enter the name of the variable and then Save. Do this for all 4 variables (event_category, event_label, event_name, event_value)

After the creation, you should be able to see these variables in the list. Now, we can use these variables in the Tags.

Triggers setup

After the variables have been added, a trigger must be configured. The trigger will help recognize the events originating from Ajax Search Pro.

To setup a trigger hit the Triggers menu, and click the New button. Name the trigger "Ajax Search Pro Events" and choose Custom Event as the event type. Enter asp_event as the Event name and hit Save.

Now, we can use the asp_event from the Data Layer to connect to a Tag.

Tags setup

In this example, we will convert the asp_event to a Google Analytics 4 Event to a with a specific tracking ID.

Go to the Tags menu and click the New button. Name the tag as you like, we are using "Ajax Search Pro GA4 Event" in the example. Click the Tag Configuration area and choose Google Analytics: GA4 Event.

Choose to set the Configuration Tag manually, by choosing "None - Manually Set ID", and enter your google analytics Measurement ID.

For the Event name choose the Event variable or enter {{event_name}}

Almost done, now all we need are the Event Parameters, where we add the variables, which were created in the first step.

To the Event Parameters section add the following rows:

Parameter NameValue

event_category

{{event_category}}

event_label

{{event_label}}

event_value

{{event_value}}

Once this is done, scroll down to Triggering and Add Ajax Search Pro Events as the trigger and Save.

Measurement

After this setup all the data is now sent to the defined google Analytics 4 account. After the installation see the Events Tracking to setup the desired events to track.

Last updated

Copyright Ernest Marcinko