Cookie Zendesk

You only have a Zendesk cookie and you don't want to use Google Tag Manager to install it.

A - Locate it on your website

Here is the code that launches the Zendesk chat that you should have in your site Header

<script type="application/javascript" src="'https://static.zdassets.com/ekr/snippet.js?key=4e15810f-956f-40d6-bcab-59f8768b80c1"/>

B - The Zendesk function

We'll now transform the script and encapsulate it in a function that will launch the script (the launchZendesk() function).

function launchZendesk(){
var el = document.createElement('script');
el.setAttribute('src', 'https://static.zdassets.com/ekr/snippet.js?key=4e15810f-956f-40d6-bcab-59f8768b80c1');
el.id = "ze-snippet";
document.head.append(el);
} 

C - Integration on your website

You'll just have to add the code

<script type="text/javascript">
//Le sdk qui permet de lancer le widget Axeptio et de sauvegarder les acceptations
    var el = document.createElement('script');
      el.setAttribute('src', 'https://static.axept.io/sdk.js');
      el.setAttribute('type', 'text/javascript');
      el.setAttribute('async', true);
      el.setAttribute('data-id', '5xxXXxxXXXxxXXXxxXXXa');
      el.setAttribute('data-cookies-version', 'XXXXX');
  if (document.body !== null) {
    document.body.appendChild(el);
  }

// La fonction qui permet de lancer Zendesk
    function launchZendesk(){
        var el = document.createElement('script');
        el.setAttribute('src', 'https://static.zdassets.com/ekr/snippet.js?key=4e15810f-956f-40d6-bcab-59f8768b80c1');
        el.id = "ze-snippet";
        document.head.append(el);
    } 

// La fonction qui relie Axeptio au lancement du cookie Zendesk
    void 0 === window._axcb && (window._axcb = []);
    window._axcb.push(function(axeptio) {
      axeptio.on("cookies:complete", function(choices) {
        if(choices.zendesk) {
          launchZendesk();
        }
      });
    });
    </script>

Great ! Everything works 👌

Last updated