Allow same domain referrer logging via setDomains?


(primerano) #1

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.

Thanks
Tony


(Matthieu Aubry) #2

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: piwik/CHANGELOG.md at master · matomo-org/piwik · GitHub

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!


(Matthieu Aubry) #3

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


(primerano) #4

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


(Matthieu Aubry) #5

it is in Release candidate!


(primerano) #6

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', '*.my.internal.com/path/path2/base_application_path']);

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, '*.piwik.org/website1']) all link that goes to the same domain piwik.org but to any other path than website1/* will be treated as outlink

If I visit www.my.internal.com/path/path2/base_application_path from www.my.internal.com/some_other_site I am not seeing www.my.internal.com/some_other_site in the referrer report.

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

Thanks
Tony


#7

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


(primerano) #8

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(['trackPageView']);
  _paq.push(['enableLinkTracking']);
_paq.push(["setDomains", ["*.www-dev.my.internal.com/path/path2/base_application_path","*.www-test.my.internal.com/path/path2/base_application_path","*.www.my.internal.com/path/path2/base_application_path"]]);

  (function() {
    var u="//ubweb1.my-internal.domain.com/piwik/";
    _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);
  })();
</script>
<!-- End Piwik Code -->

(primerano) #9

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?


#10

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