How to handle User-ID backstitching for users that revoke consent

Hi!

When we implement User-ID in combination with anonymous tracking, we obviously do not want to track any User-IDs without consent of the user. But one specifc edge case is still letting us see question marks.

Here is a desciption of the case:

  1. User visits website and grants consent for full tracking with cookies
  2. User logs into the website - the user-id is collected
  3. User goes into the privacy settings and revokes consent
  4. Piwik PRO switches to anonymous tracking, so in the session log the IP adress is 0.0.0.0 and informations like city are not stored - as expected. But the collected UserID is still stitched to the session.

So while this is in fact an edge case that may not happen very often, as this is a legal matter, what solution is there to prevent Piwik PRO from storing the UserID even thou the user has revoked consent?

Hi @Martin_Frotzler,

Technically you could clear the User ID from the JSTC using the resetUserId method -API — Piwik PRO Analytics Suite 18.17 documentation
and force a new session by adding the &new_visit=1 to the next tracking request

_paq.push([“appendToTrackingUrl”, “new_visit=1”]);
_paq.push([“trackEvent”, “Session”, “Forcing New Visit”]);
_paq.push([“appendToTrackingUrl”, “”]);

Please let me know if you have any questions.

Have a great day! :slight_smile:

1 Like

Hi @kamilb , Thank you - this looks exactly like the solution we were looking for :slight_smile:

Hi,

I have a question regarding the usage of appendToTrackingUrl:

according to the docs parameter should be added without a leading “&” and you would only use it if you want to add multiple parameters at once.

I tried both variants (with and without leading “&”) in the console like…

_paq.push(["appendToTrackingUrl", "mytest=1"]);
_paq.push(["trackEvent", "Test", "Test Param"]);

on Piwik PRO tagged sites but outgoing requests used an unchganged url parameter and did not include any trace of my added parameter.

image

So my question is: how would this API call effect my outgoing requests?

best,
Markus

Hi @mbaersch,

Am I correct to assume that you expected the url parameter to be extended by mytest=1?

If my assumption is correct then it sadly won’t work that way. The appendToTrackingUrl method will append the parameter to the tracking request body or query string (example.piwik.pro/ppms.php?mytest=1), not the actual tracked URL. The name might be slightly misleading.

image

1 Like

exactly that was my assumption. Thanks - in that case, a “&” or not seems to have no effect either.

If you want to add parameters to the URL tracked within the request, you can use:

_paq.push(['setCustomUrl',"https://example.com/?test=test1"])

2 Likes

Hi @mbaersch,

You are right about the ‘&’ - I’ve edited the original response.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.