Cookie Banner Not Dissapears

Solved

Cookie Banner Not Dissapears

Nick137
Tourist
16 0 2

The issue is that the cookie banner is not disappearing and it is showing on every page no matter if you accept or decline it. It is very frustrating and inconvenient.   

Accepted Solution (1)

BSSCommerce-TC
Shopify Partner
225 49 51

This is an accepted solution.

Hi @Nick137 ,

 

Let try this one:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    const cookieValue = document.cookie.split('; ').find(row => row.startsWith('receive-cookie-deprecation='));
    if (!cookieValue) {
      document.querySelector('.privacy-bar__inner').style.display = 'block';
    } else {
      document.querySelector('.privacy-bar__inner').style.display = 'none';
    }

    document.querySelectorAll('.privacy-bar__inner button').forEach(button => {
      button.addEventListener('click', function() {
        const action = this.getAttribute('data-action');
        if (action === 'accept') {
          document.cookie = "receive-cookie-deprecation=1; path=/; max-age=" + 60*60*24*30; 
        }

        document.querySelector('.privacy-bar__inner').style.display = 'none';
      });
    });
  });
</script>

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


MIDA: Heatmap, Record & Replay |BLOOP Referral Program, Reward |

Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency

View solution in original post

Replies 10 (10)

Guleria
Shopify Partner
3953 791 1123

Hello @Nick137 ,

 

Can you please store URL and theme name you are using? 

 

Thanks

- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder
Nick137
Tourist
16 0 2

Please note that the cookie banner is showing only in the us region - https://bestbuddyramps.com/ - Impact theme

Guleria
Shopify Partner
3953 791 1123

I use VPN to check it but it doesn't appear. 

Can you enable it globally ?

btw note that in default Impact I don't find any issue like you described.

  

- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder
Nick137
Tourist
16 0 2

What would happen if i enable it globally? Please note that until yesterday i  enabled it globally, and i checked it on another devices and the issue was still there. 

Guleria
Shopify Partner
3953 791 1123

If you enable it globally, I can check the console for the error. 

 

- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder
Nick137
Tourist
16 0 2

I permitted it. Hope your idea helps me. 

Guleria
Shopify Partner
3953 791 1123

Follow these steps:

1. Go to Online Store -> Theme -> Edit code

2. Open your theme.liquid file  
here search for </body> and just before to it add this code

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var bannerElement = document.getElementById('shopify-pc__banner');
    var privacyBannerElements = document.querySelectorAll('.shopify-section--privacy-banner');

    if (bannerElement) {
      privacyBannerElements.forEach(function(element) {
        element.style.display = 'block'; // Show the elements
      });
    } else {
      privacyBannerElements.forEach(function(element) {
        element.style.display = 'none'; // Hide the elements
      });
    }
  });
</script>

 

I hope it will work. 
btw if you need a much more cleaner solution then try to ask theme support about it or hire a developer to add a code.   

Thanks

- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

BSSCommerce-TC
Shopify Partner
225 49 51

This is an accepted solution.

Hi @Nick137 ,

 

Let try this one:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    const cookieValue = document.cookie.split('; ').find(row => row.startsWith('receive-cookie-deprecation='));
    if (!cookieValue) {
      document.querySelector('.privacy-bar__inner').style.display = 'block';
    } else {
      document.querySelector('.privacy-bar__inner').style.display = 'none';
    }

    document.querySelectorAll('.privacy-bar__inner button').forEach(button => {
      button.addEventListener('click', function() {
        const action = this.getAttribute('data-action');
        if (action === 'accept') {
          document.cookie = "receive-cookie-deprecation=1; path=/; max-age=" + 60*60*24*30; 
        }

        document.querySelector('.privacy-bar__inner').style.display = 'none';
      });
    });
  });
</script>

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


MIDA: Heatmap, Record & Replay |BLOOP Referral Program, Reward |

Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency
Nick137
Tourist
16 0 2

Where i need to add this code. I will be glad to receive a step by step guidance. Thanks in advance. 

BSSCommerce-TC
Shopify Partner
225 49 51

Hi @Nick137 ,

 

Step 1:  Go to Online Store -> Theme -> Edit code >  theme.liquid

Step 2:  Insert the code before the </body> tag and Save them.

 

If our suggestions are useful, please let us know by giving it a like  and marking it as a solution. Thank you very much

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


MIDA: Heatmap, Record & Replay |BLOOP Referral Program, Reward |

Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency