Aller au contenu

Le principe

Le script SingA/B porte l’attribut data-consent="required". Tant qu’il n’a pas reçu l’accord, le visiteur voit votre page d’origine et rien n’est stocké. Votre CMP transmet ensuite le choix du visiteur par une file de commandes, window._singab, qui fonctionne avant comme après le chargement du script : l’ordre de chargement n’a pas d’importance.

Accord
window._singab = window._singab || [];
window._singab.push(['consent', 'grant']);
Refus ou retrait
window._singab = window._singab || [];
window._singab.push(['consent', 'revoke']);

Au retrait, la collecte s’arrête et tout ce que SingA/B avait écrit dans le navigateur est effacé. Le détail est sur la page Conformité.

1. Le script en mode consentement

Script SingA/B
<script async src="https://hawker.singapour.org/singab.js"
  data-config="https://hawker.singapour.org/configs/<clé-publique>.json"
  data-consent="required"></script>

2. Déclarer SingA/B dans votre CMP

Ajoutez un service, ou « vendor », personnalisé pour SingA/B, avec la finalité que vous retenez (mesure, amélioration du site). Dans les exemples ci-dessous, son identifiant est singab : remplacez-le par celui que vous avez déclaré.

Axeptio

Avec un vendor singab déclaré dans votre projet Axeptio :

Axeptio
<script>
  window._singab = window._singab || [];
  window._axcb = window._axcb || [];
  window._axcb.push(function (axeptio) {
    axeptio.on('cookies:complete', function (choices) {
      window._singab.push(['consent', choices.singab ? 'grant' : 'revoke']);
    });
  });
</script>

Didomi

Avec un vendor personnalisé, par exemple c:singab. Le choix est relu au chargement, puis à chaque changement :

Didomi
<script>
  window._singab = window._singab || [];
  function singabSyncDidomi(Didomi) {
    var granted = Didomi.getUserConsentStatusForVendor('c:singab') === true;
    window._singab.push(['consent', granted ? 'grant' : 'revoke']);
  }
  window.didomiOnReady = window.didomiOnReady || [];
  window.didomiOnReady.push(singabSyncDidomi);
  window.didomiEventListeners = window.didomiEventListeners || [];
  window.didomiEventListeners.push({
    event: 'consent.changed',
    listener: function () { singabSyncDidomi(window.Didomi); },
  });
</script>

Tarteaucitron

Avec un service personnalisé. Placez ce code après le chargement de Tarteaucitron :

Tarteaucitron
<script>
  tarteaucitron.services.singab = {
    key: 'singab', type: 'analytic', name: 'SingA/B (tests A/B)',
    uri: 'https://www.votre-site.fr/confidentialite', needConsent: true, cookies: [],
    js: function () {
      window._singab = window._singab || [];
      window._singab.push(['consent', 'grant']);
    },
    fallback: function () {
      window._singab = window._singab || [];
      window._singab.push(['consent', 'revoke']);
    },
  };
  (tarteaucitron.job = tarteaucitron.job || []).push('singab');
</script>

Une autre CMP

Toute CMP qui sait exécuter du code à l’accord et au refus fonctionne : appelez window._singab.push(['consent', 'grant']) d’un côté et window._singab.push(['consent', 'revoke']) de l’autre. Si votre CMP connaît le choix avant le chargement du script, un drapeau suffit aussi : window.singabConsent = true, ou false pour un refus.

Tester

  1. Ouvrez une page du site dans une fenêtre de navigation privée, sans répondre au bandeau.
  2. Dans la console : SingAB.consent.status vaut 'pending'.
  3. Acceptez dans le bandeau : le statut passe à 'granted', la mesure démarre.
  4. Retirez votre accord : le statut passe à 'denied' et les clés singab: disparaissent du stockage local (onglet Application des outils de développement).