Piwik shows Direct Entry but Apache log show referrers

I’m using 1.7.1 and have noticed sometimes visitors that show Direct Entry actually have the external referrers in the Piwik querystring when I check my Apache log files.Examples include traffic from Google searches, Twitter, Facebook etc

Is this a known bug?

Make sure you look at the same visit, IP, etc.
Also the referrer would be tracked only on the first page view of the visit.

I see now that the initial referrer is still passed in the query string for each subsequent hit even though these are showing up in Piwik as a few separate visits over two days. Is that correct? Or is this user possibly visiting from the same referring link each time?

However even their initial visit which matches the timestamp in Apache and Piwik is still not showing the referrer. Am I correct in thinking it is the parameter _ref that is supposed to pass this value? Something doesn’t seem right here.

pleaseput here screenshot of your visitor log and extract of your log

most likely there is no bug in piwik or someone else would have reported it :slight_smile:

I’d like to understand what’s causing it even if it’s not a bug, so here is an example referral from Twitter.

_url stores the URL that was initially used to find the website. It is kept in the cookie, to allow to credit goals/ecommerce conversions to the initial conversion.

The referrer would be sent in &urlref=

Thanks for explaining that, however I think you meant _ref not _url for the cookie data?

How long does the cookie last by the way?

Also, since the original referrer is known and passed with every hit, it would be brilliant if this info could be shown in Piwik on subsequent, separate visits.

Since at the moment it just shows “Direct Entry” if they have returned via a bookmark etc, perhaps it would be useful to show under that:

Originally from: [the original referrer]

I’m also using Piwik 1.7.1 and experiencing the same problem.
I noticed that sometimes Visitor Log doesn’t display the referer value I see for the same visit in database in the table log_visit > referer_url field

I modified /plugins/Live/templates/visitorLog.tpl adding after the

this simple code:


here a screenshot of the result


When refererer url has the same domain we do not count it as referrer as it’s not interesting info

I understand the notion that same domain is not an external referrer, therefore not to be listed in Referrers statistics…
However a same-domain-referrer can occur for various reasons, and it is a useful information stored in database that I prefer to see somewhere, at least in Visitor Log.

I have the same problem as the original poster. Only direct entries shown in the reports, but in my case there is a &urlref= parameter in the logs.Other things suich as browser, screen resolution etc. are recorded, but no referrer and then of course no search engine keywords. Another thing that is missing are the pages in the Actions/Pages report. only “Page URL not defined”. I do get the page title report, however.

This is a log entry (my domain replaced by example.com)

212.201.xx.xx - - [07/Aug/2012:16:30:48 +0200] "GET /piwik/piwik.php?action_name=Schulung%2520NoSQL%2520Einf%25C3%25BChrung%2520%257C%2520Example&idsite=1&rec=1&r=390371&h=16&m=30&s=48&url=http%253A%252F%252Fexample.com%252Fschulung_nosql_einf%2525C3%2525BChrung&urlref=http%253A%252F%252Fwww.google.de%252Furl%253Fsa%253Dt%2526rct%253Dj%2526q%253D%2526esrc%253Ds%2526source%253Dweb%2526cd%253D14%2526ved%253D0CFsQFjADOAo%2526url%253Dhttp%25253A%25252F%25252Fexample.com%25252Fschulung_nosql_einf%252525C3%252525BChrung%2526ei%253D-xkhUKuEJIOE4gSE64DABg%2526usg%253DAFQjCNFCiHyd92B_4J3RRO0YTUZ7RKtvOg&_id=f0f963e26f4772e9&_idts=1344349849&_idvc=1&_idn=1&_refts=1344349849&_viewts=1344349849&_ref=http%253A%252F%252Fwww.google.de%252Furl%253Fsa%253Dt%2526rct%253Dj%2526q%253D%2526esrc%253Ds%2526source%253Dweb%2526cd%253D14%2526ved%253D0CFsQFjADOAo%2526url%253Dhttp%25253A%25252F%25252Fexample.com%25252Fschulung_nosql_einf%252525C3%252525BChrung%2526ei%253D-xkhUKuEJIOE4gSE64DABg%2526usg%253DAFQjCNFCiHyd92B_4J3RRO0YTUZ7RKtvOg&pdf=0&qt=1&realp=0&wma=0&dir=0&fla=1&java=1&gears=0&ag=1&cookie=1&res=1280x800 HTTP/1.1" 200 326 "http://example.com/schulung_nosql_einf%C3%BChrung" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20100101 Firefox/14.0.1"

I use Piwik 1.8.2. The site is a Drupal site, with the Piwik code inserted in the template (not using the Piwik module).

Thanks for any advise.

Is there a redirect in place to your piwik.php by any chance? look with Firefoxu, firebug NET panel, to see if doing any redirect before reaching piwik? redirect could change the parameters and lose referrer and page

Hi Matt,

Thank you for the answer. No redirect, it returns http code 200, and the normal Piwik one-liner in the body. Everything seems to work fine, except these two parameters. There are the ModRewrite entries of a typical Drupal installation, but piwik is excluded from that (otherwise it wouldn’t work at all).

The parameter &urlref= is encoded twice - maybe you have a rule that encodes the content?

Thank you very much, Matt, that was it. There was indeed a redirect which I overlooked before, and that did the double encoding. Everything works fine now.

There is, however, something that looks like a little bug to me.

The site is reacheable via two domains, say example-site.com and examplesite.com. There is this redirect from examplesite to example-site that caused the problem. When I look in Piwik at settings / websites, there is only one, namely example-site.com. That is ok, except when I click on View Tracking Code, there is the code with examplesite.com in it.

I might have installed Piwik by calling the Piwik installation from examplesite.com -&nbspThis website is for sale! -&nbspexample site Resources and Information. (I don’t remember), but now nowhere in the settings is any trace of examplesite.com, except in the tracking code, where I can’t get rid of it.

It is not a problem for me any longer, I just modified the tracking code in the Drupal template, but there seems to be some inconsistency within the Piwik settings.

Thanks for the report. It will be fixed as part of: New Super User setting to edit the Piwik hostname · Issue #3230 · matomo-org/matomo · GitHub


I’m having almost all visitors (99% of them) coming from search engines appear as Direct Entry. Some of them (very few) do appear as organic and show the search keywords.
All visitors coming from referral sites show up correctly.
I can’t figure out what the problem might be.
Piwik was installed automaticaly by Softaculous and i copied the tracking code exactly as it was provided.
I’ve used Piwik in the past with other sites and had no such problems.

The trouble site is top50solar.ro

The tracking code installed is

And i’m accesing piwik at Piwik › Sign in

So no redirects are involved.
Any ideea?
I’m using 1.11.1

My situation is very similar to topsolar. Nearly all of my referers show up as Direct Entry. There are only 2 domains so far that actually show up correctly: t.co and newswithtags.com

I posted a link to my site here:


Checking the response headers don’t show any referrer nor does the cookie for Piwik. Apache logs don’t show it as well. I’m fairly new to this, but not sure where where to start looking. I have full control over the domain and server.

Since my last post I’ve only had 5 counted visitors coming from reffering sites and 2 coming from search engines using my domain name as the keyphrase.
This is very strange.
As I’ve told you before, I have installed piwik on many other sites and I’ve never encountered this problem until now.

Yep, same here.

Have you tried checking your request headers or apache logs to see if the referer even shows up there?