Matomo User ID configuration

Updated: Thursday, December 21, 2023

User ID: what is it?

The User ID feature is used by most web analytics tools on the market to uniquely identify a logged-in visitor across multiple devices.

If your website doesn’t offer visitors the option to log in, User ID will be useless for you.

Without the User ID, web analytics tools only rely on cookies and fingerprinting to identify a visitor. However, these solutions have their limitations:

  • it’s not really the visitors who are identified, but the devices. If visitor A uses a different device, they will be considered as a new visitor B by the analytics tool.
  • if cookies are deleted between two visits from visitor A, then they will be considered a new visitor (unless the fingerprint has not changed).
  • if the cookies are deleted and the fingerprint changes between two visits by visitor A, then they will be considered a new visitor.

User ID and the law

Depending on the data you send as User ID, this can be either :

  • Directly identifying personal data (email address, surname).

  • Indirectly identifying personal data (e.g. system ID: 123456). In other words, the data alone cannot be traced back to a physical person, but by cross-referencing this data with data from your user management system, it can.

Both types can be referenced to as PII (Personally Identifiable Information).

To use this feature, you must therefore obtain the visitor’s consent.

Anonymize User ID

In Matomo, it is possible to hash or anonymize the User ID before storing it in the database. This offers greater respect for the visitor’s privacy.

Go to Settings (gear at top right of the interface) then Privacy and then Anonymize data.

Then check the box Replace user ID with a pseudonym.

This anonymization feature does not make the User Id not PII, so you will still need to obtain consent.

Configure User ID in Matomo

To send the User ID to Matomo, you must already have this data in the Data Layer.

You can either send the User Id when loading the tracking code, as follows:

<!-- Matomo -->
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['setUserId', 'USER_ID_HERE']);
  (function() {
    var u="";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src='//'; s.parentNode.insertBefore(g,s);
<!-- End Matomo Code -->

Or, if the information is sent later (after the tracking code), it should be followed by a page view:

_paq.push(['setUserId', 'USER_ID_HERE']);

Visualise User ID in Matomo interface

In Matomo, the User Id is visible in the visitor profiles of the visit log.

User Id dans le profil visiteur dans Matomo
User Id dans le profil visiteur dans Matomo

And also in the Visitors > User ID report.

Rapport User ID dans Matomo
Rapport User ID dans Matomo

Didn't find what your were looking for?

Get help from the Data Marketing Club

Join the club