Allow same domain referrer logging via setDomains?

I have a need to track referrers within the same domain. Within our intranet we have several sites that live on the same domain but are in different paths,

If someone visits http://myintranetdomain/foo from http://myintranetdomain/bar I (as the owner of /foo) would like to know that.

Since setDomains allows paths, can this also be used to indicate what referrers should be considered local?

For example.

If I set

_paq.push(['setDomains', 'myintranetdomain/foo]);

Referrals from http://myintranetdomain/bar should be tracked because I explicitly set the /foo path thus /bar would not be local.

I think setDomains is usually used to expand what is considered local but it would be nice if this or another API allowed users to limit the scope of local.

Thoughts? Somewhere I saw that campaigns can be used for this tracking but I’m not running a campaign so it seems a little forced.


You are very lucky! We have just implemented this feature in PIwik core. Please try with 2.16.0 beta which should work well for your use case. Find more details of what’s changed in:

If you find any feedback with this new feature in the beta, please let us ASAP as we’d like to make sure it works well in 2.16.0 release coming up in a few days!

make sure you upgrade to our beta (which is very stable FYI), see I would like to test early beta and RC releases, how do I enable automatic updates to use these development versions? - Analytics Platform - Matomo

Is there an ETA for 2.16.0 to be out of beta?

it is in Release candidate!

I got this installed now and I am testing it out but I am still not seeing referrers from the same domain name. Are referrers updated in real time? About page has “About Piwik 2.16.0-rc1”

My piwik setDomains looks similar to this

_paq.push(['setDomains', '*']);

The changelog only mentions outlinks and not referrers

“The JavaScript Tracker method PiwikTracker.setDomains() can now handle paths. This means when setting eg _paq.push(['setDomains, '*']) all link that goes to the same domain but to any other path than website1/* will be treated as outlink

If I visit from I am not seeing in the referrer report.

Let me know if I should see this or if I have done something incorrectly.


Did you also configure the URLs including path in each website in the administration of Piwik?

Yes. I think the admin settings are correct.

In “Manage Websites” under URLs I have

I’m tracking dev/test and prod under the same site

And in the page source I have the following before I guess I should move this to head but that should not matter right?

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['setUserId', 'user set server side']);
  _paq.push(['setDocumentTitle', 'env set server side / Welcome']);  
_paq.push(["setDomains", ["*","*","*"]]);

  (function() {
    var u="//";
    _paq.push(['setCookiePath', '/path1/path2/base_application_path']);
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 2]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
<!-- End Piwik Code -->

It seems to be working now. I think maybe it was not tracking my tests as referrers because I had already visited the page via bookmark.

Are referrers only tracked when a user’s piwik cookie is first set?

Glad it’s working now. Referrers are tracked on the first action of a visit, which is usually a pageview. On a new visit (eg 30 minutes later), referrers will be tracked again even though Piwik cookie might already exist