Cross domain tracking in Usermaven

What is Cross-domain tracking?

Cross-domain tracking in web analytics allows you to track user behavior across multiple websites or domains as if they were one. Without it, tracking users across multiple platforms becomes a major hurdle.

If your business operates on several domains, users navigating between them appear as separate visitors on each domain. This misidentification skews your understanding of user engagement and journey, leading to fragmented data and inaccurate insights.

For example, imagine a customer browsing your online store on one domain and completing their purchase on another. Without cross-domain tracking, these visits appear as disconnected events, hindering your understanding of their complete journey. This means users like John Doe, who visits both www.example.com (opens in a new tab) and www.example.org (opens in a new tab), are recognized as the same individual throughout their journey.

Technical implementation

To enable cross-domain tracking, you'll need to add a specific snippet after the Usermaven tracking pixel that you must have already installed. This snippet includes the data-domains parameter where you specify the domains you want to track.
Here’s how you can do it:

  • Usermaven tracking pixel setup:

You already have the Usermaven tracking script installed, most likely placed just below the opening <head> tag of your website's HTML. You’ll be adding two additional attributes just below the script. This is what the complete code should look like:

<script type="text/javascript">
(function () {
      window.usermaven = window.usermaven || (function () { 
(window.usermavenQ = window.usermavenQ || []).push(arguments); })
      var t = document.createElement('script'),
          s = document.getElementsByTagName('script')[0];
t.defer = true;
t.id = 'um-tracker';
t.setAttribute('data-tracking-host', "https://um.example.com")
t.setAttribute('data-key', 'XXXXXXXX');
t.setAttribute('data-autocapture', 'true');
t.setAttribute('data-randomize-url','true');
t.src = '[https://um.example.](https://um.example.io/lib.js)com[/lib.js](https://um.example.io/lib.js)';
 
// additional attributes [⭐](https://emojipedia.org/star)
t.setAttribute('data-cross-domain-linking','true');
t.setAttribute('data-domains','example.com,example.org');
 
s.parentNode.insertBefore(t, s);
})();
</script>

The data-cross-domain-linking parameter is set to true by default and can be set to false if you wish to disable cross-domain tracking for specific scenarios. Moreover, remember to replace "example.com,example.org" with a comma-separated list of your actual domain names.

  • For the legacy tracking pixel:

If you're still using the legacy Usermaven pixel, the process is similar. Locate the script and at the very end (before the closing >), you’ll have to add two attributes. This is what your script will look like:

<script src="[https://um.example.](https://um.postnitro.ai/lib.js)com/lib.js"
data-key="XXXXXXXX"
data-tracking-host="https://um.example.com"
data-autocapture="true"
data-randomize-url="true"
data-cross-domain-linking="true" // additional attribute [⭐](https://emojipedia.org/star)
data-domains="example.com,example.org" // additional attribute [⭐](https://emojipedia.org/star)
defer>
</script>
 
<script>window.usermaven = window.usermaven || (function(){(window.usermavenQ = window.usermavenQ || []).push(arguments);})</script>  

Thus when a user navigates from one domain to another within your platform, Usermaven's cross-domain tracking feature automatically attaches a query parameter to the URL of the destination domain. This parameter acts as an identifier, carrying information about the user's activity on the source domain. A decorated URL might look like this:

[https://example.org/?_um=*abc*](https://example.org/?_um=*abc*)  

This mechanism ensures that the user is recognized as the same individual on both domains, enabling seamless tracking of their journey. Additionally, cross-domain tracking isn’t compatible with cookie-less configurations. It functions exclusively with cookie-based tracking.

Benefits of Cross-Domain Tracking

Here’s how cross-domain tracking can be of great value to you:

  • Unified User View: Gain a holistic understanding of user behavior across all your domains.

  • Accurate Attribution: Track conversions and revenue accurately across touchpoints on different domains.

  • Enhanced Analytics: Analyze user journeys, funnels, and engagement metrics with comprehensive data.

  • Data-Driven Decisions: Make informed business decisions based on reliable insights about your multi-domain user base.

Thus, by implementing cross-domain tracking in Usermaven, you can ditch the headaches of fragmented data. You'll get a complete picture of how users journey across your different websites, no matter which domain they're on.