Cross domain tracking makes it possible for Piwik to record the same visitor on two related websites, for example an Ecommerce website and a separate shopping cart website, as a single visit.
Why is setting up cross domain needed for accurate visitor tracking across domains? Piwik uses a visitor ID to record visit data. Visitor ID values are stored in cookies on the web domain of the visit. These cookies are first party cookie and can only be accessed on the specific domain name that they were created, so other domain names cannot access these cookies and the visitor ID. So when you need to track your visitors across different domains, the visitor ID must be forwarded from one domain to the other domain using a special mechanism which we call Cross domain linking, described in detail below.
To setup accurate cross domain tracking, follow these steps:
Configure your domain names as Alias URLs for your Piwik website. Login to Piwik and click on Administration > Websites > Manage. Edit your website, and specify all your domain names in the Alias URLs field. There may be two or more domains.
_paq.push(["setDomains", ["*.domain1.com", "*.domain2.com"]]); _paq.push(["enableCrossDomainLinking"]);
Check that the Cross Domain linking is working correctly. Go to your domain1.com and click on a link to your domain2.com. If Cross Domain linking is enabled and working, the URL of domain2.com will contain a new parameter
pk_vidparameter will contain a string of data which includes the Visitor ID. This way the current visitor ID is forwarded to the page of the different domain. Similarly when a user clicks from domain2.com to domain1.com, the domain1.com URL will also have this new
You have successfully configured Cross Domain linking: congratulations!