If you work in the CRO area, you are most likely familiar with AB Tasty. It is one of the leading web experimentation tools on the market.
In this post we are going to make the most of the information that AB Tasty sends to Google Analytics 4, to better reflect the insights obtained with each experiment.
Starting point: AB Tasty’s integration with GA4
AB Tasty has a native connector that allows easy integration with GA4.

Just add the ID of the Google Analytics 4 data stream and start working.

This integration generates the following elements:
- An event, whose name is
abtasty. - Two event parameters:
abtasty_campaigncontaining the id and name of the experiment.abtasty_variation, which includes the id and name of the variation.
All of this can be viewed at dataLayer:

These parameters must be registered in GA4 as custom dimensions. I like to prefix it with “int_” to keep a homogeneous nomenclature between integrations:

In this way, the parameters will arrive correctly to Google Analytics 4…

…and you can use them in GA4 Explorations using segments: by adding the name of the experiment, you can compare the behavior between variations.
However, from my point of view, this has an important limitation: The parameters associated with the event abtasty are only linked to that event on dataLayer. Therefore, when generating more activity or navigating to another page, the traceability of the experiment is lost. Furthermore, doing analysis from GA4 scans is not the most optimal or scalable way to draw conclusions.
The solution: persistent variables
The way to guarantee this traceability is to make the variables persistent during the user’s session. To do this, we will create with Google Tag Manager first-party cookies that will drag these parameters across multiple pages.
Step 1: identify and reference the AB Tasty variables in the dataLayer
The first thing to do is to create the variables that allow us to “fish” from dataLayer the campaign name and the experiment variation. In GTM, go to Variables -> user-defined variables -> new:

The variables of the dataLayer are hosted inside the subobject eventModel. Thus we will reference it in the field “data layer variable name”, so that:
- To retrieve the parameter
abtasty_campaign, we will enter:eventModel.abtasty_campaign - To retrieve the parameter
abtasty_variation, we will enter:eventModel.abtasty_variation

Step 2: create first party cookies
The next step is to transform the dataLayer variables into first-party cookies through a custom HTML tag:

This function creates first-party cookies on the root domain, so that these cookies are persistent between related subdomains: www.mywebsite.com, blog.mywebsite.com, shop.mywebsite.com, etc. At the end of the session, the cookie expires.
This tag uses two auxiliary functions called setCookie and getRootDomain. At the end of the article you can download all the elements of this implementation.
Step 3: Label activation
Once created, the tag should only fire when the event abtasty has been triggered and the user has given consent to create this type of cookie. This screenshot shows an example of triggering with OneTrust as CMP:

Step 4: Send parameters to GA4
Finally, we send the value of these cookies to GA4. We go back to the GTM Variables section and create two new variables of type 1st Party Cookie, indicating the names:
abtasty_campaignabtasty_variation


Then, we add these variables to the variable of type “Google Tag: Event Settings” as additional parameters:


Benefits of this solution
Benefit 1: a new conversion funnel
Imagine that your goal is to capture leads and you want to validate which version of your page best motivates the user to initiate and complete a contact form. Thanks to this implementation, you will be able to build a funnel of users who have followed the following sequence
abtasty -> form_start -> lead
First-party cookies allow the analysis to be performed on GA4 data, since both the name and the variation of the experiment persists in interactions after viewing one version of the page or another:

Benefit 2: use Looker Studio for your analyses
Thanks to this enhanced traceability, GA4 data will be more consistent and you will be able to perform descriptive analysis with Looker Studio, streamlining the decision-making process and improving the quality of insights:

Considerations and limitations
When implementing this solution, the following should be taken into account:
- All execution depends on the explicit consent of the user. If you reject cookies, none of the above will occur.
- The solution only monitors activity from the moment the user interacts with an experiment. Previous activity will not be associated. If you want to do this, you will need BigQuery.
- If a user participates in two different experiments during the same session (which is not recommended), the variables will follow the last wins logic, with the value of the last experiment prevailing. Again, to analyze such cases, you will have to resort to BigQuery.
Materials for download
Here you have a .zip file with all the elements described during this post. I hope you liked it and that it will be useful for you.
