What is UserID?

Each time a new visitor enters your page, Piwik PRO assigns a cookie to him containing a random string of characters. The purpose of this cookie is for Piwik PRO to be able to recognize the same visitor whenever he visits your website again. However, instead of a random string, you can set your visitors with your own human-friendly name (ex. visitor email). All you need to do to achieve that is to pass the correct value to the Piwik tracking code.

Implementing UserID

Piwik PRO Tag Manager provides an automatic setup of UserID, you only need to create a variable that will be catching the userID value. The value can be anything you like but it’s important for it to be unique to avoid confusing visitors. In the example below, the value will be an email address of logged in user.

First of all, you need to verify if the email address is provided anywhere on your page for you to grab.

When you find it, just right-click it and inspect it to reveal the code.

Our code has an id parameter so it can easily be grabbed by the Piwik PRO Tag Manager

Now all you need to do is setup your tracking code so it will be passing the variable to Piwik.

That’s it – you are now tracking UserID in the Piwik PRO!

Manually using UserID feature

If for some reason you are unable to use automatic setup within Piwik PRO Tag Manager, you’ll need to add UserID method to your Piwik JavaScript tracking code manually.

All you need to add is following line

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

Just before the


line in your standard JavaScript tracking code.

Of course, it will be up to you to pass the correct value in the ‘USER_ID_HERE’ place.

Why use UserID?

Except for the fact that UserID allows you to easily recognize your visitors, it also provides another great benefit. UserID will be recognizing returning visitors across multiple devices. No matter if your visitors log into your website from his computer, phone or tablet, you will always know that it’s the same person! Please also note that whenever your visitor log out and his userID value is no longer available, he will start being tracked as a new visit using the standard random string cookie.

Was this article helpful?

Be the first to rate this article.

Technical Support

If you have any questions, drop us a line at

We’re happy to help!