How can I track visitors based on the visitor ID cookie instead of the IP address?

Piwik PRO, by default, tracks a visitor based on the visitor ID cookie (if visitor supports cookies) and/or matches the user fingerprint collected from the IP address and user device information (in cases when a visitor does not support cookies).

There are some situations when tracking the visitors with the vIsitor ID cookie does not work as expected (for instance when you use Piwik PRO on an intranet and all visitors have the same IP address).

If you want to make sure that all visitors are tracked correctly on your intranet, you have two choices: use the UserID feature in Tag Manager or set the UserID feature manually.

Use UserID feature

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.
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 set up your tracking code so it will be passing the variable to Piwik PRO.

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 the 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.

  • If you cannot use User ID, alternatively you can edit your config/config.ini.php and add the following:

[Tracker]trust_visitors_cookies = 1

Now, even if all visitors have the same IP, OS, browser configuration, etc. they will be tracked as unique visitors based on the first party cookies. If you don’t set it up, you the number of visits will be lower.

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!