templates/partials/rudderstack_script.html.twig line 1

Open in your IDE?
  1. <script>
  2.     rudderanalytics = window.rudderanalytics = [];
  3.     const methods = [
  4.         "load",
  5.         "page",
  6.         "track",
  7.         "identify",
  8.         "alias",
  9.         "group",
  10.         "ready",
  11.         "reset",
  12.         "getAnonymousId",
  13.         "setAnonymousId",
  14.         "getUserId",
  15.         "getUserTraits",
  16.         "getGroupId",
  17.         "getGroupTraits",
  18.         "startSession",
  19.         "endSession",
  20.         "getSessionId"
  21.     ];
  22.     for (let i = 0; i < methods.length; i++) {
  23.         const method = methods[i];
  24.         rudderanalytics[method] = (function (methodName) {
  25.             return function () {
  26.                 rudderanalytics.push(
  27.                     [methodName].concat(Array.prototype.slice.call(arguments))
  28.                 );
  29.             };
  30.         })(method);
  31.     }
  32.     rudderanalytics.load('{{ rudderstack_key }}','{{ rudderstack_dataplane_url }}');
  33.     rudderanalytics.page();
  34.     {% if app.user %}
  35.     rudderanalytics.identify("{{ app.user.id }}", {
  36.         idCP: "{{ app.user.adId }}",
  37.         IP: "{{ get_user_ip() }}",
  38.     });
  39.     {% endif %}
  40.     const minutPass = document.querySelector("#minut-pass");
  41.     if (minutPass) {
  42.         minutPass.addEventListener("click", function () {
  43.             rudderanalytics.track("Audience behavior", {
  44.                 categorie: "Audience behavior",
  45.                 page: "FICHEVH",
  46.                 libelle: "Click lien de prise de RDV",
  47.                 type_utilisateur: {% if app.user and app.user is pro %}"Pro"
  48.                 {% elseif app.user %}"Particulier"{% else %}""{% endif %},
  49.                 url_destination: document.querySelector("#minut-pass").getAttribute('href'),
  50.                 url_provenance: window.location.href,
  51.                 valeur: "",
  52.                 valeur_empty: "false",
  53.             });
  54.         });
  55.     }
  56. </script>
  57. <script src="https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js"></script>