CookieYes Javascript

A modified version of our tag for clients using CookieYes cookie manager on their website

If you are using CookieYes for your cookie management on your website, you may require some customisation to our default JavaScript to avoid issues with your attribution and tracking.

🚧

Recommendation

We recommend using a 'full screen' cookie consent banner with CookieYes

CookieYes can block the creation of analytics cookies until the user consents. This means analytics solutions can't track users if they don't interact with the cookie consent banner when they arrive on the website.

Additionally, CookieYes may reload the page after consent is given, which can strip out the original document.referrer value. This can negatively impact attribution tracking, as referrer data is often used to identify where users came from.

👉 To avoid this, we recommend disabling the page reload option in the CookieYes banner settings:

Go to Cookie Banner → Advanced Settings in your CookieYes dashboard and turn off “Reload page on consent action”.

For information on customising your cookie consent banner, visit CookieYes Documentation.

If your website uses Cookie Yes to manage cookie consent, please use this version of the Ruler tracking script.

❗️

Replace your Site ID

Please replace INSERT YOUR SITE ID HERE on line four of the code below with the Ruler Site ID for your tracking site.

Your unique Site ID can be found in your dashboard here

<script>
  function initializeRulerTracking() {
    window.__raconfig = window.__raconfig || {};
    window.__raconfig.uid = "INSERT YOUR SITE ID HERE";
    window.__raconfig.action = "track";

    (function () {
      var ra = document.createElement("script");
      ra.type = "text/javascript";
      ra.src = "https://ruler.nyltx.com/lib/1.0/ra-bootstrap.min.js";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(ra, s);
    })();
  }

  function handleConsentUpdate(eventData) {
    var data = eventData.detail;
    if (data.accepted.includes("analytics")) {
      initializeRulerTracking();
    }
  }

  document.addEventListener('cookieyes_banner_load', function(eventData) {
    var data = eventData.detail;
    if (data.categories.analytics) {
      initializeRulerTracking();
    } else {
      document.addEventListener('cookieyes_consent_update', handleConsentUpdate);
    }
  });
</script>

This script should be applied to 'all pages' where Cookie Yes is enabled.

If you are implementing your Ruler tag via Google Tag Manager, you can apply this script as Custom HTML tag.

If implementing via Google Tag Manager, you can use custom Cookie Yes event triggers in Google Tag Manager, but this is not necessary.

For more information or support please email [email protected]