cookieconsent icon indicating copy to clipboard operation
cookieconsent copied to clipboard

[Bug]: Inconsistent data-category behavior

Open Naatan opened this issue 4 months ago • 0 comments

Expected Behavior

data-category="!analytics" fires on each page load if consent was not given.

Current Behavior

data-category="!analytics" only fires the moment consent is refused, which is inconsistent because data-category="analytics" fires both when consent is given as well as on page load.

Steps to reproduce

<script
    type="text/plain"
    data-category="analytics">
    console.log("consent given");
</script>
<script
    type="text/plain"
    data-category="!analytics">
    console.log("consent not given")
</script>

Add the following to a page and load the page. First time (without any consent having been given or rejected) nothing will fire.

When consent is given the "consent given" string will log, and upon page refresh it will again log this string.

Now open preferences and reject consent. The "consent not given" will be logged, but upon reload nothing is logged.

Proposed fix or additional info.

Make data-category="!analytics" fire on page load. This supports the use case of wanting to run distinct logic on whether consent was given or not.

Version

3.1.0

On which browser do you see the issue?

Firefox

Naatan avatar Oct 15 '25 15:10 Naatan