Skip to main content

See Uxify's A/B split in Google Analytics

Rebuild Uxify's lift and direct attribution numbers from your own analytics data

Written by Simeon Totev

Uxify uses two small cookies to tell your website which test group each visit is in and when a Uxify agent kept a shopper on your site. This article shows how to send that information to Google Analytics 4 (GA4) so you can compare the results yourself. You do not need to be a developer.

How the Uxify A/B split works

Uxify runs an ongoing A/B test on your site to measure how much it helps your sales. At the start of every visit, Uxify puts the visit in one of two groups:

  • Optimized: the visit gets the Uxify features that are part of the test, for example faster page loads with Navigation AI.

  • Control: the visit sees your site without those features. Uxify still measures the visit, so the two groups can be compared fairly.

Uxify picks the group at random. Your Uxify settings decide how big the control group is (also called the holdout). For example, with a 10% holdout, about 1 in 10 visits is in control.

The group belongs to the visit, not the person. The same shopper can be optimized on Monday and in control on Thursday. The group does not change during a visit.

The two Uxify cookies

The Uxify script stores two cookies on your own domain. Other code on your pages, such as your Google Analytics code, can read them.
​

uxify_group

  • Contains the group of the current visit: optimized or control.

  • Lasts 24 hours. Uxify renews it on every page the visitor opens.

uxify_direct

  • Contains the names of the Uxify agents that kept this visitor on your site in the last hour (a direct save, explained below). If there is more than one name, they are separated by commas, for example Emma or Emma,Max.

  • Lasts 1 hour after the most recent save. The cookie does not exist if no save happened.

When the cookie appears: on the first page of a visit, Uxify asks its server for the group in the background. The uxify_group cookie is written as soon as the answer arrives, usually in a fraction of a second. If Uxify cannot reach its server, the visit counts as control.

For developers: both cookies are first-party, readable by JavaScript (document.cookie), and set with Path=/ and SameSite=Lax, plus Secure on HTTPS pages. No Domain is set, so each subdomain has its own copy.

What Uxify does with Google Analytics today

Uxify already reads your standard GA4 purchase event and uses it to count orders in your Uxify dashboard.

Uxify does not send anything to your Google Analytics property. GA4 does not know which group a visit was in until you add the snippet below. The setup takes about 15 minutes.

Step 1: Add the snippet to your site

This setup is for GA4 installed with the gtag.js code in your site's template. Ask the person who manages your site code to paste the snippet below on every page, directly above your existing Google tag code (the block that loads googletagmanager.com/gtag/js). Do not change your existing Google tag code.

The snippet keeps checking the cookies while the page is open, because they can change: the group arrives a moment after the first page starts, it can change on sites that switch pages without reloading, and uxify_direct appears after a save and expires an hour later. Every GA4 event carries the current values.

<!-- Uxify A/B group for Google Analytics -->
<script>
(function () {
// Queues commands for gtag.js. It runs before the Google tag code,
// so the values are already set for the first page_view.
window.dataLayer = window.dataLayer || [];
function uxifyGtag() { window.dataLayer.push(arguments); }

function uxifyCookie(name) {
var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
return match ? decodeURIComponent(match[1]) : '';
}

var lastGroup = null;
var lastDirect = null;

// Sends the current cookie values to GA4, only when one of them changed.
function syncUxifyValues() {
var group = uxifyCookie('uxify_group') || 'unknown';
var direct = uxifyCookie('uxify_direct') || 'none';
if (group === lastGroup && direct === lastDirect) return;
lastGroup = group;
lastDirect = direct;
uxifyGtag('set', { uxify_group: group, uxify_direct: direct });
}

syncUxifyValues();

// Browsers with the Cookie Store API report cookie changes right away.
if (window.cookieStore && typeof window.cookieStore.addEventListener === 'function') {
window.cookieStore.addEventListener('change', syncUxifyValues);
}
// All browsers: check again every second. This also notices when
// uxify_direct expires, which not every browser reports as a change.
setInterval(syncUxifyValues, 1000);
})();
</script>

Shopify stores: if you send GA4 events from a custom pixel (Settings > Customer events), the pixel cannot read document.cookie. Inside each event handler, read the values with await browser.cookie.get('uxify_group') and await browser.cookie.get('uxify_direct'), and add them to the event you send.

Step 2: Add the custom dimensions in GA4

GA4 only shows the new values in reports after you register them as custom dimensions. You only need to do this once per GA4 property.

  1. In GA4, open Admin. Under Data display, click Custom definitions.

  2. Click Create custom dimension and enter:

    • Dimension name: Uxify group

    • Scope: Event

    • Event parameter: uxify_group

  3. Repeat with the dimension name Uxify direct save, the scope Event and the event parameter uxify_direct.

Important: use Event scope, not User scope. The group can change from one visit to the next. A User-scoped dimension keeps only the latest value for each person, which mixes up the two groups.

New custom dimensions only collect data from the moment you create them. Standard reports can take 24 to 48 hours to show it. To see the data sooner, open your site through Google Tag Assistant and watch Admin > DebugView in GA4.

Step 3: Build your A/B report

  1. In GA4, open Explore and start a Free form exploration.

  2. Under Dimensions, click +, import Uxify group and drag it to Rows.

  3. Under Metrics, import Sessions, Ecommerce purchases, Purchase revenue and Session key event rate. Drag them to Values.

  4. Choose a date range that starts after you added the snippet.

You now see one row for optimized and one for control. Compare rates per session, not totals:

  • Do optimized visits buy more often? Divide Ecommerce purchases by Sessions for each group.

  • Do optimized visits earn more? Divide Purchase revenue by Sessions for each group.

  • How much better is optimized? (Optimized rate − Control rate) ÷ Control rate.

Example: with a 10% holdout, the control group has about one ninth as many sessions as the optimized group, so its total revenue is naturally much lower. Compare revenue per session instead: if optimized earns €2.20 per session and control earns €2.00, optimized earns 10% more per session.

You can also add Uxify group as a secondary dimension in standard reports, such as Reports > Monetization > Ecommerce purchases, or use it as a filter in Looker Studio.

Track direct saves by Uxify agents

Two Uxify agent tools step in when a visitor is about to leave:

  • Carter (cart rescue) asks a visitor with items in the cart to stay when they try to leave the site.

  • Drafter (form rescue) asks a visitor who started a form but did not finish it to stay when they try to leave the site.

When the visitor chooses to stay and keeps using the page, Uxify counts a direct save and adds the agent's name to the uxify_direct cookie. This is the name you gave the agent in Uxify. If you rename the agent, new saves use the new name.

The cookie lasts one hour, so an order placed while it exists happened within one hour of a save. To see these orders in GA4:

  1. Create a Free form exploration as in Step 3.

  2. Import the Uxify direct save dimension and drag it to Rows.

  3. Add the metrics Ecommerce purchases and Purchase revenue.

Rows with an agent name (for example Emma) are orders placed within an hour of that agent's save. The none row contains all other orders.

Tip: a direct save is a moment you can see: the visitor wanted to leave and stayed. The A/B report measures the full effect of Uxify, including things visitors never notice, such as faster pages. Use both together.

Good to know before you read the numbers

  • The first page view of a new visitor can show unknown. GA4 often sends its first page view before Uxify has written the cookie. Later events, including the purchase, carry the group. When you compare groups, filter out unknown and (not set).

  • The first page view of a returning visitor can show the group from their previous visit. This only affects that one page view. Purchases are not affected.

  • GA4 and Uxify count sessions differently. Expect the totals to be close, but not identical. The comparison between groups is still fair, because GA4 counts both groups the same way.

  • Visitors who block cookies or tracking do not appear. This affects both groups equally.

  • Each subdomain has its own cookie. If your shop and checkout are on different subdomains (for example www. and checkout.), make sure the Uxify script and the snippet run on both.

  • Give the test time. Small differences over a few days are often chance. Compare at least two full weeks.

  • Cookie consent. Your GA4 tags follow your consent settings as before. If you are not sure whether your cookie banner should mention the Uxify cookies, ask your privacy contact.

Troubleshooting

How do I check that the cookie exists? Open your site in Chrome and browse two pages. Right-click the page, choose Inspect, open the Application tab, then Cookies and your site's address. Look for uxify_group. In Firefox, the same list is under the Storage tab.

The cookie is missing. Check that the Uxify script is installed on the page. Ad blockers in your own browser can also block it, so test in a private window with extensions turned off.

The cookie exists, but GA4 shows nothing.

  • Check that you created the custom dimension in GA4 and that the parameter name is exactly uxify_group, all lowercase.

  • Wait 24 to 48 hours for standard reports. DebugView shows data within seconds.

  • Check that the snippet is on every page, directly above your Google tag code.

Almost every session is in one group. This is normal when your holdout is small: with a 5% holdout, about 95% of sessions are optimized. Compare rates per session, not totals.

The uxify_direct report only shows none. Direct saves only happen when Carter or Drafter is turned on for one of your agents, and only when a visitor chooses to stay. On a small site this can take a while. Check in your Uxify dashboard that the agent records saves.

Did this answer your question?