Referrer and search engine tracking doesn't work

It seems that Piwik doesn’t track the referrer URLs. We got only 5-10 search referers per day on Piwik, which is far less than the real numbers (according to Google Analytics 6000+ visitors came from search engines a day).

Other analytics seem to work fine.

Do you have any idea what causes this issue?


The only thing i can thin of is a redirect (e.g. from http to https on your site) interfering with the referrer data.

Maybe check the data the browser is sending to piwik. If you visit your site, it should send a request similar to the virtual drums dev team&idsite=3&rec=1&r=837126&h=19&m=28&s=3&url=

Especially look at the urlref parameter, as this is what piwik records.

We use https only on specific pages like login, signup etc, not on general sites.
However Piwik is on an https URL, can it cause any trouble?

Okay, that shouldn’t create an issue. What does the urlref parameter say?

Here it is:

urlref= means that the referrer is correct (Google isn’t sending keywords anymore)

So how does this visit show up in piwik?

I checked the segmented visitor log which came from Google, but the visit didn’t show up.
We pass a username to piwik, do you think it has to do something with this issue?

If the user is not logged in Piwik associates the visitor with the name “undefined”. Most of the case visitors coming from Google are not logged in, maybe Piwik aggregates all these people and handles it as ONE user and this is what causes this issue?

I have not used the user ID feature, but that seams possible. After reading User ID - Analytics Platform - Piwik and JavaScript Tracking Client: Integrate - Piwik Analytics - Developer Docs - v3 I think the ID should always be unique for each logged in user.

And logged out users should just have no user ID set:

var _paq = _paq || [];

// If used is logged-in then call 'setUserId' 
// $userId variable must be set by the server when the user has successfully authenticated to your app.
if (isset($userId)) {
     echo sprintf("_paq.push(['setUserId', '%s']);", $userId);


Another advantage is that this way you can track when your users log out.

Yes, that was the problem. If anyone who uses Tag Manager and comes across with this issue, this is what the solution looks like:

if (typeof {{userName}} !== ‘undefined’) {
_paq.push([‘setUserId’, {{userName}}]);

It seems that referers are correctly logged now.