Webhooks
You want to send user choices to your server
Several methods are possible to send a user's choices to your server
1
window._axcb = window._axcb || [];
2
window._axcb.push(function (axeptio) {
3
axeptio.on('cookies:complete', function (choices) {
4
fetch('/backend/consent', {
5
method: 'POST',
6
body: {
7
settings: axeptio.settings,
8
choices: choices
9
}
10
}).then(function (response) {
11
console.info('successfully saved user preferences');
12
}).catch(function (error) {
13
console.info('something went wrong');
14
})
15
});
16
});
Copied!

Option 2a : register the token generated by Axeptio and use a webhook

1
window._axcb = window._axcb || [];
2
window._axcb.push(function (axeptio) {
3
axeptio.on('ready', function () {
4
fetch('/backend/token', {
5
method: 'POST',
6
body: { token: axeptio.settings.token }
7
}).then(function (response) {
8
console.info('successfully saved user token');
9
}).catch(function (error) {
10
console.info('something went wrong');
11
})
12
});
13
});
Copied!
Send a POST request for the webhook creation :
1
POST https://api.axept.io/v1/webhooks
2
Authorization: Bearer XXXXXXXXXXXXX <-- your bearer token
3
{
4
"method": "POST",
5
"url": "https://www.yourwebsite.com/backend/consent",
6
"event": "consent/XXXXXXXXXXXXX" <-- your project Id
7
}
Copied!

Option 2b : specify the Axeptio token and use a webhook

1
<script>
2
window.axeptioSettings = {
3
clientId: "XXXXXXXXXXXX",
4
cookiesVersion: "ga_only",
5
token: <?php echo json_encode(session_id()) ?>
6
};
7
(function(d, s) {
8
var t = d.getElementsByTagName(s)[0], e = d.createElement(s);
9
e.async = true; e.src = "//static.axept.io/sdk.js";
10
t.parentNode.insertBefore(e, t);
11
})(document, "script");
12
</script>
Copied!
Send a POST request for the webhook creation :
1
POST https://api.axept.io/v1/webhooks
2
Authorization: Bearer XXXXXXXXXXXX <-- your bearer token
3
{
4
"method": "POST",
5
"url": "https://www.yourwebsite.com/backend/consent",
6
"event": "consent/XXXXXXXXXXXXX" <-- your project Id
7
}
Copied!
Last modified 8mo ago