Skip to content

Using Abrantes with a tag management solution

Osvaldo edited this page Jan 5, 2026 · 10 revisions

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.

With Google Tag Manager

You can use this html page to test the following steps. Make sure you:

  1. Replace GTM-M7XW88 by your own Google Tag Manager ID
  2. Edit <script src="../AbrantesPlus.js"></script> linking to your AbrantesPlus.js location.

1. Create the event variables

  • Create the Data Layer variable DLV - ab_test_data with the Data Layer Variable Name ab_test_data
  • Create the Data Layer variable DLV - experiment_name with the Data Layer Variable Name experiment_name
  • Create the Data Layer variable DLV - variant_name with the Data Layer Variable Name variant_name

2. Create a trigger

  • Create the trigger DL event is run_ab_test as a custom event with the event name run_ab_test.

3. Create a custom html tag to test it

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

4. Inspect the page with the tag assistant

With the Google tag assistant check that:

  1. There's a "run_ab_test" event
  2. The variables in that event and the following events exist: DLV - ab_test_data, DLV - experiment_name and DLV - variant_name

5. Next steps

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.

Clone this wiki locally