A/B Testing

You want to display a widget based on the utrl or an UTM

1. Video presentation

2. Configuration details

In this case, we want to display a specific widget based on the origin UTM of your user. For this, we'll have to create multiple cookies versions with recognizable versions names.

It is important to display an UTM with the word Facebook or LinkedIn in the URLs based on the user's origin

Now you can get the sdk to integrate to your website

Finally, when integrating the SDK, you'll have to add the code below :

el.setAttribute('data-cookies-domain', 'Nom de domaine');
// Here we switch the version depending whether or not URL parameters of the page contains
// utm_source=maif.
   if (window.location.href.match('Facebook')){
   el.setAttribute('data-cookies-version','version Facebook');
 }
   if (window.location.href.match('Linkedin')){
   el.setAttribute('data-cookies-version','version Linkedin');
 }
 else {
   el.setAttribute('data-cookies-version','version Normale');
 }

window._axcb = [function(axeptio){
  var cookiesLink = document.getElementById('cookies');
  if(cookiesLink) {
    cookiesLink.addEventListener('click', function(){
      axeptio.openAxeptioCookies();
    });
  }

Which gives :

var el = document.createElement('script');
el.setAttribute('src', 'https://static.axept.io/sdk.js');
el.setAttribute('type', 'text/javascript');
el.setAttribute('async', true);
el.setAttribute('data-id', '5e1748dea2db270f66a1b048');
el.setAttribute('data-cookies-domain', 'Nom_de_domaine');
// Here we switch the version depending whether or not URL parameters of the page contains
// utm_source=maif.
   if (window.location.href.match('Facebook')){
   el.setAttribute('data-cookies-version','version Facebook');
 }
   if (window.location.href.match('Linkedin')){
   el.setAttribute('data-cookies-version','version Linkedin');
 }
 else {
   el.setAttribute('data-cookies-version','version Normale');
 }

window._axcb = [function(axeptio){
  var cookiesLink = document.getElementById('cookies');
  if(cookiesLink) {
    cookiesLink.addEventListener('click', function(){
      axeptio.openAxeptioCookies();
    });
  }
}];document.body.appendChild(el);

Split visitors between several versions

If you want to split your visitors randomly between several versions of your widget, you'll have to implement a new Javascript function in the Axeptio HTML Tag :

// List of the different versions on which we'll run the tests
var versions = ["version_A", "version_B", "version_C"];  /// TODO CHANGE NAMES HERE
// If the user already have a particular version, we get it back
var version = window.localStorage.getItem("axeptio_cookies_version");
// Or we pick one randomly in the array
if (!version) {
  version = versions[Math.floor(Math.random() * versions.length)];
  // And save the chosen version
  window.localStorage.setItem("axeptio_cookies_version", version);
}
window.axeptioSettings = {
  clientId: "5c3c5a155a51d93d6b7bc156", /// TODO CHANGE ID HERE
  cookiesVersion: version,
};
(function (d, s) {
  var t = d.getElementsByTagName(s)[0],
    e = d.createElement(s);
  e.async = true;
  e.src = "//static.axept.io/sdk.js";
  t.parentNode.insertBefore(e, t);
})(document, "script");

Congratulations ! 👌

Dernière mise à jour