How to activate cross-domain tracking

2 min read. This guide describes how to track users across your domains: website and booking engine.

Victoria Sweeney avatar
Written by Victoria Sweeney
Updated over a week ago

Cross-domain tracking allows you to track a visitors journey from your website to your booking engine accurately. Without cross-domain tracking, a visitors journey would end once they leave your website and they would be counted again as new visitor once they land on your booking engine. Implementing cross-domain tracking is important for the reliability of your Google Analytics data and requires working together with your web developer and booking engine provider to implement the script.

How to implement the script?

The cross-domain script is an add on to your Universal Google Analytics script. If you do not have Google Analytics on your website and booking engine yet please see here.

The following script, which activates the cross-domain tracking has to be added to your Universal Analytics code, on two different domains: your website and your booking engine ⚠️  

For your website:

ga('create', 'UA-XXXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['bookingengine.com']);
ga('send', 'pageview');

For your booking engine:

ga('create', 'UA-XXXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['hotelwebsite.com']);
ga('send', 'pageview');


After adding the cross-domain script your Universal Analytics code should look like this:

<!-- Google Analytics -->

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-61386642-1', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', ['thebookingbutton.co.uk']);
    ga('send', 'pageview');

</script>

<!-- End Google Analytics -->


The next step is to include both domains in the referral exclusion. Universal Analytics excludes all traffic from the domains that are listed in the referral exclusion. This way the traffic will not be measured twice. More info on referral exclusion can be found here.

  1. Go to your Google Analytics account

  2. Go to 'Admin'

  3. Click 'Tracking Info' in the 'PROPERTY' column

  4. Click 'Referral Exclusions List'

  5. Click '+Add Referral Exclusion' 

  6. Enter the domain for your exclusion (domain of your website and booking engine)

  7. Enter the name of the domain

  8. Click 'Create' to save the new exclusion

For more questions about this topic, you can ask a question through the Hotelchamp Platform chat or contact [email protected]

Did this answer your question?