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 :
1
el.setAttribute('data-cookies-domain', 'Nom de domaine');
2
// Here we switch the version depending whether or not URL parameters of the page contains
3
// utm_source=maif.
4
if (window.location.href.match('Facebook')){
5
el.setAttribute('data-cookies-version','version Facebook');
6
}
7
if (window.location.href.match('Linkedin')){
8
el.setAttribute('data-cookies-version','version Linkedin');
9
}
10
else {
11
el.setAttribute('data-cookies-version','version Normale');
12
}
13
14
window._axcb = [function(axeptio){
15
var cookiesLink = document.getElementById('cookies');
16
if(cookiesLink) {
17
cookiesLink.addEventListener('click', function(){
18
axeptio.openAxeptioCookies();
19
});
20
}
Copied!
Which gives :
1
var el = document.createElement('script');
2
el.setAttribute('src', 'https://static.axept.io/sdk.js');
3
el.setAttribute('type', 'text/javascript');
4
el.setAttribute('async', true);
5
el.setAttribute('data-id', '5e1748dea2db270f66a1b048');
6
el.setAttribute('data-cookies-domain', 'Nom_de_domaine');
7
// Here we switch the version depending whether or not URL parameters of the page contains
8
// utm_source=maif.
9
if (window.location.href.match('Facebook')){
10
el.setAttribute('data-cookies-version','version Facebook');
11
}
12
if (window.location.href.match('Linkedin')){
13
el.setAttribute('data-cookies-version','version Linkedin');
14
}
15
else {
16
el.setAttribute('data-cookies-version','version Normale');
17
}
18
19
window._axcb = [function(axeptio){
20
var cookiesLink = document.getElementById('cookies');
21
if(cookiesLink) {
22
cookiesLink.addEventListener('click', function(){
23
axeptio.openAxeptioCookies();
24
});
25
}
26
}];document.body.appendChild(el);
Copied!

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 :
1
// List of the different versions on which we'll run the tests
2
var versions = ["version_A", "version_B", "version_C"]; /// TODO CHANGE NAMES HERE
3
// If the user already have a particular version, we get it back
4
var version = window.localStorage.getItem("axeptio_cookies_version");
5
// Or we pick one randomly in the array
6
if (!version) {
7
version = versions[Math.floor(Math.random() * versions.length)];
8
// And save the chosen version
9
window.localStorage.setItem("axeptio_cookies_version", version);
10
}
11
window.axeptioSettings = {
12
clientId: "5c3c5a155a51d93d6b7bc156", /// TODO CHANGE ID HERE
13
cookiesVersion: version,
14
};
15
(function (d, s) {
16
var t = d.getElementsByTagName(s)[0],
17
e = d.createElement(s);
18
e.async = true;
19
e.src = "//static.axept.io/sdk.js";
20
t.parentNode.insertBefore(e, t);
21
})(document, "script");
Copied!
Congratulations ! 👌
Last modified 9mo ago