Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set a random visitor ID at each requests instead of using 0000000… for anonymous analytics #5095

Closed
alexgarel opened this issue Feb 29, 2024 · 4 comments · Fixed by #5107
Closed

Comments

@alexgarel
Copy link
Member

What

We decided that to track statistics without being "personal" we will use a uid of 00000… to report to Matomo.

This create two problems:

  • it breaks the queue system of Matomo which is based upon VisitorID to decide which queue to send data to. Because we have a lot of requests on user 0, the queue 0 is a lot more targeted and the process worker can't cope with it (more entering requests than it is capable of processing).
  • another point (less blocking) is that it breaks matomo graphics as a single user have a great number of actions

Proposal

Do not define user id (uid) for anonymous stats and instead use a random visitor id that change on every requests.

Note: as queue is based upon the first letter of visitor id, ensure it's evenly distributed.

This way we would solve both problems: nicer graphs and better queues distribution.

Related issue

Issue on matomo side (as I though it was a bug on their side): matomo-org/plugin-QueuedTracking#231

@monsieurtanuki
Copy link
Contributor

Do not define user id (uid) for anonymous stats and instead use a random visitor id that change on every requests.

I didn't follow everything regarding matomo but it looks like we put the same value for conceptually different IDs: the visitor ID (e.g. the device id) and the visitor user ID (e.g. the user email).

I assume that what is bothering you is the visitor ID, that uses one single bucket ('0') for all non-consenting users on the server side.
It also look like you're not supposed to change the visitor ID.
A quick fix would be to compute a random letter, to store it locally, and to reuse it as the start of the visitor ID (right-padded with 0s) when the user is not consenting. Dividing the world of non-consenting users in 26 evenly distributed regions.
@alexgarel What do you think of that?

Food for thoughts:

cf. matomo.dart:

  /// The [visitorId] should have a length of 16 characters otherwise an
  /// [ArgumentError] will be thrown. This parameter corresponds with the
  /// `_id` and should not be confused with the user id `uid`. See the
  /// [Visitor] class for additional remarks. It is recommended to leave this
  /// to `null` to use an automatically generated id.

cf. visitor.dart:

  /// The unique visitor ID, must be a 16 characters hexadecimal string.
  ///
  /// Corresponds with `_id`.
  ///
  /// Every unique visitor must be assigned a different ID and this ID must not
  /// change after it is assigned. If this value is not set Matomo will still
  /// track visits, but the unique visitors metric might be less accurate.
  ///
  /// Think of this as a device ID; in case of website tracking (where Matomo
  /// originates), this would be the cookie identifying the browser and not
  /// necessarily a user (since a single browser might be used by multiple
  /// users).
  final String? id;

  /// The [User ID](https://matomo.org/guide/reports/user-ids/) is any non-empty
  /// unique string identifying the user (such as an email address or an
  /// username).
  ///
  /// Corresponds with `uid`.
  final String? uid;

@alexgarel
Copy link
Member Author

@monsieurtanuki your solution is smart and seems perfect :-)

@monsieurtanuki
Copy link
Contributor

@monsieurtanuki your solution is smart and seems perfect :-)

With such an enthusiastic comment I was somehow forced to code it today 😉

@monsieurtanuki monsieurtanuki removed their assignment Mar 8, 2024
@alexgarel
Copy link
Member Author

@monsieurtanuki because it will take time to deploy this fix to every one, I am manually patching matomo to do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants