Skip to content

Fix for opt-out toggling on page load and incorrect default state #19879

@KiwiKilian

Description

@KiwiKilian

Expected Behavior

The opt-out checkbox should only change when clicked. The checkbox and text should display the actual current state of the users choosen settings.

  • If the cookie mtm_consent_removed is set, the opt-out text should state, the user has opted-out. The checkbox should not be checked and say: "You are currently opted out. Check this box to opt-in."
  • If there is no mtm_consent_removed cookie set, the checkbox should be checked and the text should say: "You are not opted out. Uncheck this box to opt-out."

Current Behavior

Everytime the page with the opt-out is loaded, the state of the opt-out is toggled. So if there is no mtm_consent_removed cookie set, it will be set. Meanwhile the checkbox and text displays the opposite of the cookie state. It seems like the JS is just toggling the state everytime.

Steps to Reproduce (for Bugs)

  1. Create a page that only inlcudes the tracking snippet and the opt-out snippet
  2. Simply reload the page multiple times

Context

We are trying to implement the cookieless, opt-in method. Therefore the tracking code has set the following options:

    _paq.push(["setDoNotTrack", true]);
    _paq.push(["disableCookies"]);
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);

No other cookies are set for the domain. There are results beeing tracked by this example page.

(The different single and double quote styles are actually generated by Matomo UI).

Your Environment

  • Matomo Version: 4.12.1 (previously also occured on 4.12.0)
  • PHP Version: 7.4.3
  • Server Operating System: Linux
  • Additionally installed plugins: CustomVariables
  • Browser: Chrome, Firefox
  • Operating System: macOS

Metadata

Metadata

Assignees

Labels

BugFor errors / faults / flaws / inconsistencies etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions