Track a Visitor Across Domains and Subdomains

If you want to tie together data from two or more separate sites — domains or a domain and its subdomains — and track the visitor and their session as one across those websites, you need to set it up properly in Piwik PRO.

The setup is different when you have separate domains, for example, clearbank.com and blog.com, and when you have a domain and its subdomains, for example, clearbank.com and help.clearbank.com. But the result is the same, you see how the visitor moves across linked websites.

In general, if you set up two websites as separate ones in Piwik PRO, then your reports will look like this:

If you set up the same two websites as one website and set up a proper linking in Piwik PRO, then you will holistically see data and the report will look more like this:

In this article, we’ll show you how to arrange that.

Before you start

Before you begin setting up tracking, get familiar with a few things:

  • When linking a few websites, you set up one Piwik PRO’s website for two or more websites that you want to track.
  • You will have one tracking code for all domains and subdomains that you want to track as one.
  • To track linked websites you will need to adjust the tracking code using Tag Manager. It’s easy, all you need to do is switch on the relevant option for the Piwik PRO tag.
  • To track the visitor across different domains, Piwik PRO uses the cross-domain mechanism which transfers the visitor ID from one domain to another domain. This way Piwik PRO understands that this is the same visitor. To pass on the visitor ID the mechanism attaches the ID to the URL of the following domain.
  • To track the visitor across a domain and its subdomain, Piwik PRO uses a wildcard cookie domain to store the cookie.

Set up cross-domain tracking for different domains

Now, let’s create a Piwik PRO website with your domains, for example, clearbank.com and blog.com, and adjust cross-domain tracking.

To set up cross-domain tracking, follow these steps:

  1. Go to Menu > Administration.
  2. Navigate to Websites & apps.
  3. Click Add new website or app.
  4. Name the website or app.
  5. In URLs, input domains, for example, https://clearbank.com and https://blog.com, and click Save.
  6. Double-check if the domains are typed correctly.
  7. Install the tracking code on your domains by following this guide.
  8. Go to Menu > Tag Manager.
  9. On the left, click Piwik PRO. This is the tag with the tracking code.
  10. Toggle Enable cross-domain tracking.
  11. Scroll down to the bottom and click Save.
  12. In the top-right corner, click Publish to make the changes go live.

Check that cross-domain works

Now, the tracking code will collect data from linked websites and present it in one set of reports. But before we view reports, we’d better check if the cross-domain tracking is working correctly.

To check the cross-domain tracking, follow these steps:

  1. Open your first domain.
  2. Move to the second domain.
  3. Check the URL for the second domain. It should have attached the ?pk_vid= parameter. If it does it means that Piwik PRO transfers the visitor ID from first to second domain.

Set up tracking for a domain and its subdomains

When you have a domain and its subdomains, for example, clearbank.com and help.clearbank.com, the setup will be different. 

To set up tracking for a domain and its subdomains, follow these steps:

  1. Go to Menu > Administration.
  2. Navigate to Websites & apps.
  3. Click Add new website or app.
  4. Name the website or app.
  5. In URLs, input domains, for example, https://clearbank.com and https://help.clearbank.com, and click Save.
  6. Double-check if the domains are typed correctly.
  7. Install the tracking code on your domains by following this guide.
  8. Go to Menu > Tag Manager.
  9. On the left, click Piwik PRO. This is the tag with the tracking code.
  10. Toggle Set cookie domain and input the wildcard domain where the cookie will be stored. For example, *.clearbank.com.
  11. Scroll down to the bottom and click Save.
  12. In the top-right corner, click Publish to make the changes go live.

Optionally, for this setup, you can check if the cookie was created for the wildcard domain, for example, .clearbank.com instead of for the non-wildcard domain, for example, clearbank.com.

View reports

In both cases, reports will present combined data for linked websites, and the visitor and their session will be counted as one. Only, after the setup, wait about 30 minutes for data collection and take a look at reports.

To view the report, follow these steps:

  1. Go to Menu > Analytics or Analytics (New)
  2. Navigate to the report that you want to see. For example, the pages report.
Was this article helpful?

Be the first to rate this article.

Technical Support

If you have any questions, drop us a line at support_SPC@piwik_SPC.pro.

We’re happy to help!