In order to track events from Luigi’s Box Search and Recommender in GA4, your website must contain the dataLayer variable.
To start tracking events in your GA4 property, you need to create a new GA4 tag in Google Tag Manager (GTM). You have two options to set up the tag:
- Import the tag
- Set up the tag by yourself
Method #1: Import the tag
The first, easier method to set up Luigi’s Box tracking in Google Analytics 4 is to import a GTM container with a tracking tag.
- Download this json file with GTM container.
- Go to the admin section in your GTM account and click “import container.”
3. Choose the downloaded file and select your existing workspace.
4. Select the import option “MERGE”. This is very important since choosing the other option will rewrite all your current tags. We recommend selecting an option to “Rename conflicting tags, triggers, and variables.”
5. Add your Google Analytics 4 property tracking id.
You can find it in your GA4 account at admin > data streams > Web stream details
6. Publish the tag
7. Continue with setting the custom dimensions in GA4.
Method #2: Creating a tag
Add a new tag
- Create a new tag in GTM by clicking Add new tag.
Insert tag name
- Enter a tag name, for example, “GA4 – Luigi’s Box Event”
Select tag type
- In the Tag Configuration section, select Google Analytics tag type: GA4 Event
Pick configuration tag
- In the Configuration tag dropdown menu, select the configuration tag of your account. If you do not have one, enter the Tracking ID of your GA4 property.
Note: If you are not sure, if you have a configuration tag in your GTM, you can find out by simply searching the tag type “Google Analytics: GA4 Configuration” in the list of tags.
Enter event and parameter names
Event:
- luigisbox
Event Parameters:
- service
- interaction
- result_type
- result_id
- user_input
See the Description of parameters section below for an explanation of individual parameters.
Variables setup
Create a variable for each parameter
In the Value column, click the + icon on the right side. Click + to add a new variable.
You will see a list of variables in your GTM. Click the + icon at the top right.
Enter the variable name, e.g. “DL – service”. (DL stands for a Data Layer.)
Select the Data Layer Variable type.
For Data Layer Variable Name, enter the variable name exactly as shown in this tutorial: “luigisbox.” + a variable name, e. g. luigisbox.module_type. You need to add “luigisbox.” before the variable name.
If the value entered in the field is different from the table below, values will not be recorded.
Variable name – Value in the DataLayer Variable Name field
- service – luigisbox.service
- interaction – luigisbox.interaction
- result_type – luigisbox.result_type
- result_id – luigisbox.result_id
- user_input – luigisbox.user_input
Add a trigger
Your event parameters are now set.
Now, create a trigger for the tag. In this case, you want to trigger the tag each time that “luigisbox” event is pushed in datalayer. To do this, click at triggering.
Add a new trigger
- Click + to add a new trigger.
- Select a trigger type “Custom event”
Set the trigger
- Add a name for your trigger, for example “Event – luigisbox”
- Set trigger event “luigisbox”
Test and publish tags
Your tracking is now set. Save the tag and publish the container changes.
We recommend testing settings before publishing via the “Preview” tool.
Register event parameters in GA4
To see all event values in GA4 reports and create segments based on Luigi’s Box events values, you’ll have to register the event parameters as custom dimensions in GA4.
To do that, navigate to admin, choose custom definitions, and create a new custom dimension.
Set custom dimensions for all the parameters
- dimension name: preferably the same name as the event parameter
- scope: event
- description: optional – describe the custom dimension
- event parameter: set the parameter name (service, interaction, result_type)
How can I verify if my settings are correct?
You have two options: quick check in standard report or comprehensive overview in Exploration section. In both cases please wait for 24-48 hours after GTM configuration.
A/ Quick check in standard report:
- Navigate to the Events report (Reports > Engagement > Events)
- In the list of events select “luigisbox”
3. Now you can see the overview for a “luigisbox” event.
4. On the bottom of the page you can see tables based on custom dimensions: service, interaction, result_type, result_id and user_input
B/ Comprehensive overview in Exploration section
- Navigate to the Exploration section and create new Free form (Explore > Free-form)
- In Variables section scroll down to DIMENSIONS and import dimensions Event name, service and interaction
3. Build a table, with:
- Dimensions (Event name, service, interaction)
- Metric (Active users, Event count)
- Filter (Event name exactly matches “luigisbox”
A/B tests
In case you want to launch an A/B test of Luigi’s Box features, you need to add additional user property ‘ab_test’ to your GA4 event tag.
Open your tag and add the new user property ab_test
Create a new dataLayer variable for ab_test
Register the user property in GA4 custom variables.
To do that, navigate to admin, choose custom definitions, and create a new custom dimension.
Create a new dataLayer variable with value luigisbox.ab_test
- dimension name: preferably the same name as the event user parameter
- scope: user
- description: optional – describe the custom dimension
- event parameter: ab_test