Webhooks Axeptio

Vous souhaitez envoyer les choix utilisateurs à votre serveur

Plusieurs méthodes sont possibles pour envoyer les choix d'un utilisateur à votre serveur.

Option 1 : Envoyer les choix au serveur via une requête Ajax (recommandé)

window._axcb = window._axcb || [];
window._axcb.push(function (axeptio) {
    axeptio.on('cookies:complete', function (choices) {
        fetch('/backend/consent', {
            method: 'POST',
            body: {
                settings: axeptio.settings,
                choices: choices
            }
        }).then(function (response) {
            console.info('successfully saved user preferences');
        }).catch(function (error) {
            console.info('something went wrong');
        })
    });
});

Option 2a : Enregistrer le token généré par Axeptio et utiliser un webhook

window._axcb = window._axcb || [];
window._axcb.push(function (axeptio) {
    axeptio.on('ready', function () {
        fetch('/backend/token', {
            method: 'POST',
            body: { token: axeptio.settings.token  }
        }).then(function (response) {
            console.info('successfully saved user token');
        }).catch(function (error) {
            console.info('something went wrong');
        })
    });
});

Envoi d'une requête POST pour la création du webhook :

POST https://api.axept.io/v1/webhooks
Authorization: Bearer XXXXXXXXXXXXXX <-- your bearer token
{
    "method": "POST",
    "url": "https://www.yourwebsite.com/backend/consent",
    "event": "consent/XXXXXXXXXXXXXX" <-- your project Id
}

Option 2b : spécifier le token pour Axeptio et utiliser un webhook

<script>
    window.axeptioSettings = {
        clientId: "XXXXXXXXXXXX",
        cookiesVersion: "ga_only",
        token: <?php echo json_encode(session_id()) ?>
    };
    (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");
</script>

Envoi d'une requête POST pour la création du webhook :

POST https://api.axept.io/v1/webhooks
Authorization: Bearer XXXXXXXXXXXXX <-- your bearer token
{
    "method": "POST",
    "url": "https://www.yourwebsite.com/backend/consent",
    "event": "consent/XXXXXXXXXXXXXX" <-- your project Id
}

Dernière mise à jour