OptOut cookie piwik_ignore usage without iFrame inclusion

Hi all,

we face a problem regarding opt out and maybe someone here can help us out:

We have a matomo running under analytics.domain.tdl (piwik_ignore is set with this domain)
We have a website under domain.tdl (here we use straight forward js tracking with opt out iframe, everything is fine)
We have a react webapp under demo.domain.tdl. Here we want to track certain infos in the server using https://www.npmjs.com/package/matomo-tracker

In this webapp we wan’t to respect the opt out of a user, but we can not read the opt out cookie, cause it`s domain is analytics.domain.tdl not *.domain.tdl. We have found no way to change this.

The question now is, what information/param must be sent with the tracking call from the webapp to make the opt out effective and NOT track any call from a client, which has the opt out cookie set?

Any ideas are very welcome!

TIA and best regards

Hi,

This may help you:

https://developer.matomo.org/guides/tracking-javascript-guide#optional-creating-a-custom-opt-out-form

You can create an custom opt-out form in JS that sets the cookie on the current website.

Hi,

thank you very much for the fast response and the hint. Unfortunately the method isUserOptedOut seems not to be available. This is dummy code trying to use it:

  <script type="text/javascript">
    var _paq = _paq || [];
    (function() {
      var u="//analytics.domain.tld/";
      _paq.push(['setTrackerUrl', u+'piwik.php']);
      _paq.push(['setSiteId', '10']);
      _paq.push([function () {
        if (this.isUserOptedOut()) {
          console.log("opt out");
        } else {
          console.log("opt in");
        }
      }])
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
      g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
    })();
  </script>

This results in: Uncaught TypeError: this.isUserOptedOut is not a function
Looking at ‘this’ in the debuggers shows, I am in the context of the tracker as I see it`s functions but isUserOptedOut is not visible.

It is also not mentioned in the JS API in the docs. Maybe it is not available anymore?

Hi,

This feature is quite new. Are you using the latest Matomo version (3.5.0)?

Indeed we are stuck on an older matomo. We will try to update first and check on this issue later.

1 Like

Hi,

we managed to update to version 3.5.1 and the function is avalilable now. Thanks for the hint!

Sorry to bother again, but the function is not quite working as I expected. I can now use

this.optUserOut()
this.forgetUserOptOut()
this.isUserOptedOut()

The last function is reflecting the status set by the first two functions, but it does not reflect the presence of a piwik_ignore cookie, means it does not reflect the status set by the normal Opt-Out-Module.
The other way round, the normal Opt-Out-Module does also not reflect to status set by the functions mentioned above.
Both behaviours are, what I would expect.

Am I getting something wrong here? Are there any restrictions regarding domain, ports etc?

As far as I’m aware off, the OptOut Iframe solution uses a 3rd-party-cookie (it is saved for the Matomo domain) and the new method uses a 1st-party-cookie (it is saved for the Domain you are using it).

1 Like

Yea, looks like this. Thanks for the tip. It does not help the way we hoped for, but it is usefull anyway.