How to store consent between two different domains ?

Loïc
Loïc
  • Updated

Want to keep the consent from one domain to another? Here's how to do it!

Once the user has made his choice, his consent is stored in our database with an anonymous identifier named "Token".

You can pass the consent between two domains by passing this Token in a Query String parameter axeptio_token.

For example, if I'm on my site site.com and I want to pass the consent on my domain mywebsite.com, I will have to pass the token in the link to mywebsite.com :

<ahref="https://www.mywebsite.com?axeptio_token=42321jg21fs29dn6cv7">

If you have several links pointing to your second site, you can pass the token automatically to the different links upon consent.

Here is an example code:

window._axcb = window._axcb || [];
window._axcb.push(function (a) {
a.on("cookies:complete", function (c) {
c = document.querySelectorAll("a");
c.forEach(function (b) {
var d = b.getAttribute("href");
if (d && d.startsWith("http")) {
var g = new URL(d);
var e = window.location.hostname
if (e !== g.hostname && d.match(/mywebsite.com/)) {
g.searchParams.set("axeptio_token", a.getToken());
b.href = g.href;
}
}
});
});
});

 

Therefore, all links pointing to mywebsite.com will have the token added to them to retrieve the user's consent.

Our SDK will take care of the rest 😉

Was this article helpful?

15 out of 17 found this helpful