I have an issue with my agency’s website. We integrated a cookie consent banner from an external source, which is Usercentrics, and this bug only happens one one page of the website.
When clicking on “Accept”, the cookie banner doesn’t go away, while it does on every other pages.
Nothing appears in the console, I’m a bit lost here…
If anyone has any idea how I could debug this, it would be very much appreciated!
So I found that the issue with the banner not disappearing was this snippet of code I put to add an onclick attribute to my buttons “Kontaktieren Sie uns”.
I found this code on the forum, which used to work perfectly (and works on all the other pages) but somehow it clashes with the cookie banner on this page.
<script>
window.onload = function() {
var anchors = document.getElementsByTagName('*');
for(var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
anchor.onclick = function() {
code = this.getAttribute('whenClicked');
eval(code);
}
}
}
</script>
Since I have two buttons I want to track the clicks of, I tried modifying “document.getElementsByTagName(‘*’);” to “document.getElementsByClassName(‘cd-button’);”
But the tracking doesn’t work…
Any help would be very much appreciated I’ve been stuck on this for so long now…