Cross Domain Tracking or Site Linking

When to use: Cross-domain tracking allow Analytics to see sessions on two different websites as a single session. This is sometimes called site linking. You may use cross domain tracking

  1. when you have multiple domains
  2. when you are using 3rd party payment gateway
  3. if you have content that displays on another domain through an iFrame or a similar technology.

How it works: In order to understand this first you have to understand how Google Analytics Track Session. The Google Analytics collects customer ID value on every hit and this customer ID value is stored in a cookie. The customer ID value in one domain is not accessible on another domain. So the Cross Domain Tracking passes this value from one domain to another domain (mostly in the Query String or URL).

//stackbug2.com/?_ga=1.210371479.3429707736.1432831029

The steps in both (website using Google Analytics or Google Tag Manager) the way to implement cross-domain tracking remain the same, only the way to achieve this is different.

1) Auto Linker: It tells Google Analytics to which other domain to link
2) Allow Link: It tells Google Analytics to check the linker parameter in the URL
3) Update Referral Exclusion List in Google Analytics

How we can achieve Cross Domain Tracking :

1) If you are using only Google Analytics then you will need to have a Tracking code modification.
2) If you are using Google Tag Manager then you will have to make some changes in the page view tag.

Using Google Analytics: Suppose you have a primary domain as stackbug.com and secondary or external domain as stackbug2.com with the below-tracking code for all of your domains (For cross-domain tracking, set up one property in your Analytics account. Use the same tracking code snippet and tracking ID from that property for all of your domains)

<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-XXXXXXX-Y’, ‘auto’);
ga(‘send’, ‘pageview’);

</script>

For Primary Domain (stackbug.com) :

Modify the Tracking code to

<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-XXXXXXX-Y’, ‘auto’, {‘allowLinker’: true});
ga(‘require’, ‘linker’);
ga(‘linker:autoLink’, [‘stackbug2.com’] );

ga(‘send’, ‘pageview’);

</script>

Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example secondary domain (stackbug2.com) with your own secondary domain name. The altered tracking code must be present on all the pages of your primary domain.
You may even add multiple secondary domains by separating them with a comma.

ga(‘linker:autoLink’, [‘stackbug2.com’, ‘stackbug3.com’] );

For Secondary Domain (stackbug2.com) :

Modify the Tracking code to

<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-XXXXXXX-Y’, ‘auto’, {‘allowLinker’: true});
ga(‘require’, ‘linker’);
ga(‘linker:autoLink’, [‘stackbug.com’] );

ga(‘send’, ‘pageview’);

</script>

Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example primary domain (stackbug.com) with your own primary domain name. The altered tracking code must be present on all the pages of your secondary domain.

You may even add multiple secondary domains by separating them with a comma.

ga(‘linker:autoLink’, [‘stackbug.com’, ‘stackbug3.com’] );

 

Using Google Tag Manager or GTM :

  • Go to your page view tag
  • Go to more setting
  • Go to Cross Domain Tracking and add a secondary domain. For multiple domains separate it by a comma.

cross domain

 

 

  • Add The allowLinker Field To Set: To do this, go to the Fields To Set dropdown and expand it. Click Add Field, and then enter allowLinker (inbuilt variable) into the Field Name field that appears. In the accompanying Value field, enter true. It should look like this

Cross Domain

 

Update Your Referral Exclusion List

When a user moves from your first domain to your second domain, it appears to Analytics that the user was referred to your second domain from your first domain and a new session is created. If you want to be able to track a single session across multiple domains, you need to add your domains to the referral exclusion list.

Steps To Update Your Referral Exclusion List:

  1. Sign in with your Analytics account.
  2. Click Admin in the menu bar at the top of any page.
  3. In the ACCOUNT column, use the drop-down to select the Analytics account that contains the property you
  4. want to work with.
  5. In the PROPERTY column, use the drop-down to select a property.
  6. Click Tracking Info.
  7. Click Referral Exclusion List.
  8. To add a domain, click +ADD REFERRAL EXCLUSION.
  9. Enter the Domain name.
  10. Click Create to save.

Please note: The referral exclusion list uses CONTAINS matching. For example, if you enter stackbug.com, then traffic from blog.stackbug.com is also excluded (because the domain name contains stackbug.com).

Please follow and like us:
569

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

www.000webhost.com