Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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.
Solved! Go to the solution
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
Hello @Nick137 ,
Can you please store URL and theme name you are using?
Thanks
Please note that the cookie banner is showing only in the us region - https://bestbuddyramps.com/ - Impact theme
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.
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.
If you enable it globally, I can check the console for the error.
I permitted it. Hope your idea helps me.
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
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
Where i need to add this code. I will be glad to receive a step by step guidance. Thanks in advance.
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
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024