Articles on: Frequently Asked Questions (FAQ)

JavaScript activated on Cookie bar acceptance

This might be useful if you are adding third-party tracking codes manually or if you want to trigger something only if the customer has accepted the terms in the Cookie bar. You can do this with the following snippet of code:

<!-- Script for executing code upon clicking on the Accept or Accept All buttons provided by the app - Consentmo GDPR -->
      function addEventListenerForAcceptBtn(adittionalChecks = 0) {
        if (window.isenseGDPR !== undefined) {
          window.addEventListener('click', function (e) {
            const isAcceptButton = && typeof === 'string' &&'isense-cc-submit-consent') >= 0 &&
              ('cc-btn-accept-all') >= 0 ||'cc-allow') >= 0);
              // ADD YOUR CODE HERE
        } else {
          if (adittionalChecks > 0) {
            setTimeout(function() {
              addEventListenerForAcceptBtn(adittionalChecks - 1);
            }, 500);

You can now proceed to add your code by replacing the line "// ADD YOUR CODE HERE". Once you have the whole snippet, including your code, you can follow the below steps so you can implement it in your store:

Navigate to your theme.liquid file. You can do this by navigating to Online Store > Themes > Actions > Edit code > theme.liquid.

Locate the <head> tag. It is at the very beginning of the file.

Copy the snippet and paste it after the <head> tag.

Note: The script will fire only if the Accept button on the Cookie bar, or the Accept All in the preferences pop up are clicked. If you are looking to have your function triggered in any other condition, you can reach our support team on or from the Chat button at the bottom right corner of your browser so they can look into this for you further.

Updated on: 24/10/2023

Was this article helpful?

Share your feedback


Thank you!