-
Notifications
You must be signed in to change notification settings - Fork 1
Using Abrantes with a tag management solution
Abrantes can work with a tag management solution like for example Google Tag Manager (GTM).
To have Abrantes working with a tag management solution use the plugin add2DL that's added by default. See the add2DL example for more information.
By default Abrantes will push the event run_ab_testwith the ab_test_data propriety, but this can be overridden by the settings yourTest.settings.dataLayer.eventName and yourTest.settings.dataLayer.customDimension. Overriding the settings is useful if you want to run more than an experiment in the same page(s).
You can inspect the dataLayer array at any moment to understand the behavior or use the tag assistant if you are using Google Tag Manager or Google Analytics.
You can use this html page to test the following steps. Make sure you:
- Replace
GTM-M7XW88by your own Google Tag Manager ID - Edit
<script src="../AbrantesPlus.js"></script>linking to your AbrantesPlus.js location.
- Create the Data Layer variable
DLV - ab_test_datawith the Data Layer Variable Nameab_test_data - Create the Data Layer variable
DLV - experiment_namewith the Data Layer Variable Nameexperiment_name - Create the Data Layer variable
DLV - variant_namewith the Data Layer Variable Namevariant_name
- Create the trigger
DL event is run_ab_testas a custom event with the event namerun_ab_test.
I've named my tag "Console log experiment details"
<script>
console.log("ab_test_data = {{DLV - ab_test_data}}");
console.log("experiment_name = {{DLV - experiment_name}}");
console.log("variant_name = {{DLV - variant_name}}");
</script>In the example a page or in a page with an experiment and the add2DL Abrantes plugin you should see the logs above in your developer tools.
Use the trigger "DL event is run_ab_test" for this tag
With the Google tag assistant check that:
- There's a "run_ab_test" event
- The variables in that event and the following events exist: DLV - ab_test_data, DLV - experiment_name and DLV - variant_name
As you have checked that the setup with Google Tag Manager works, the next step is sending the information to your analytics software. I'm using both Google Analytics 4 and Mixpanel, so the documentation will include this two. It should work with other software as well, as long as it has custom events and custom dimensions.