Cookie banner persisting across all pages

Description

I’m having an issue where even if a user has accepted the cookies, the banner shows up on every additional page that is loaded. It should hide once the cookies have been accepted but it is not doing so.

Site URL

Required: Please provide a staging/production URL where we can see the issue

Additional Context

  • Browser: Chrome
  • Device: Apple MacBook Pro

NDA Notice: If you’re under an NDA, please feel free to send us a Direct Message/Email with the above information.

Hey @llmframpton!

There’s this code snippet in your custom code section that persists the banner

window.FinsweetConsentPro = window.FinsweetConsentPro || [];
window.FinsweetConsentPro.push([
  'consent',
  (instance) => {
    // hide it immediately in case it renders before this runs
    instance.elements.banner.hide();

    const isMobile = window.matchMedia('(max-width: 767px)').matches;
    const delay = isMobile ? 6000 : 5000;

    setTimeout(() => {
      instance.elements.banner.show();
    }, delay);
  },
]);

It doesn’t matter what choice the user chooses on consentpro, the custom code reshows right back

You would need to either get rid of it or add a guard that checks for the fs-consent cookie & if present bails out

Here’s some sample code you can try out

window.FinsweetConsentPro = window.FinsweetConsentPro || [];
  window.FinsweetConsentPro.push([
    'consent',
    (instance) => {
      // hide it immediately in case it renders before this runs
      instance.elements.banner.hide();

      // don't re-prompt users who already made a choice
      const hasConsented = document.cookie
        .split('; ')
        .some((c) => c.startsWith('fs-consent='));
      if (hasConsented) return;

      const isMobile = window.matchMedia('(max-width: 767px)').matches;
      const delay = isMobile ? 6000 : 5000;

      setTimeout(() => {
        instance.elements.banner.show();
      }, delay);
    },
  ]);

Let me know!

Thank you so much for the support - that solved the issue! :slight_smile: