AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.8K members online now
4.8K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Cross domain tracking issues (campaigns, referral type, source/medium)

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I was recently made aware that our website is not properly displaying GA stats for Campaigns, Traffic Type, and Source/Medium.

 

In Campaigns, for example, if I go under Ecommerce > Product Performance, then add a Secondary Dimension for Campaign it says "(not set)" on all of my items.

 

For Source/Medium, the issue is that though we have setup our referral exclusion list, we are still seeing those referrals coming through. I read about Session Setting in the Tracking Info section, but I can't edit any of the controls on that page. This issue is causing our Traffic Type to be highly in favor of referrals.

 

Now then, this is our setup. We have our website, let's call it cupcakesaregreat.com and our shopping cart/ecommerce exists on a separate domain that is hosted by NetSuite. Also, this is how the shopping experience breaks down.

  1. cupcakesaregreat.com - click add to cart
  2. shop.cupcakesaregreat.com - click proceed to checkout
  3. checkout.netsuite.com - Login/Register page -> Shipping/Billing/Payment page -> Review Order page
  4. checkout.netsuite.com - Order confirmation page

I'm going to do my best to breakdown what our code looks like on each site/page.

 

1. cupcakesaregreat.com - our main website code is setup as follows: 

 

 

<!-- 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');

  // On every domain.
  var ga_acct;
  if ((window.location.href == "http://www.cupcakesaregreat.com/ca") || (window.location.href.indexOf('/ca/') > -1)) {
    // Canadian GA account
    ga_acct = 'UA-1234567-25';
  } else {
    // US GA account
    ga_acct = 'UA-1234567-5';
  }
  ga('create', ga_acct, 'auto', {'allowLinker': true});
  ga('require', 'linker');

  // List of every domain to share linker parameters.
  ga('linker:autoLink', ['cupcakesaregreat.com', 'netsuite.com', 'shop.cupcakesaregreat.com', 'checkout.netsuite.com']);
  ga('send', 'pageview'); // Send hits after initializing the auto-linker plug-in.

  </script>
  <!-- End Google Analytics -->

 

 

When you go from our main website (which happens when you click "Add to Cart on an item") to our shopping cart you will land on shop.cupcakesaregreat.com initially, when you click "Proceed with Order" you will go to a new domain that starts with checkout.netsuite.com. I added the "netsuite.com" in the ga linker tag above as a fail safe in case NetSuite changes their paths. I could be wrong in how I set this up, but I'm hoping you can help me with that.

 

2. shop.cupcakesaregreat.com - the initial landing when you go to the shopping cart; with NetSuite you are able to add a domain mask, but for some reason it only lasts for the initial shopping cart landing. This page is not hosted with the original cupcakesaregreat.com. Code is as follows:

 

 

<!-- Google Analytics -->
<script type="text/javascript">
 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1234567-5']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
 
</script>

<script>

var _host = window.location.host;

(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');

// On every domain.
ga('create', 'UA-1234567-5', 'auto', {'allowLinker': true});
ga('require', 'linker');

// List of every domain to share linker parameters.
ga('linker:autoLink', ['cupcakesaregreat.com', 'netsuite.com']);
ga('send', 'pageview'); // Send hits after initializing the auto-linker plug-in.

</script>
<!-- End Google Analytics -->

 

 

When you proceed with your order and move forward from the Shopping Cart page, the URL of the page will go from shop.cupcakesaregreat.com to checkout.netsuite.com, however, the code remains exactly the same for shop.cupcakesaregreat.com until the order confirmation page at which time 2 separate code bases "collide".

 

4. Order confirmation page - on this page we have the following code:

 

 

<!-- Load Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
// if the user is in the US shopping cart
if (window.location.href.indexOf("n=1") > -1 || window.location.href.indexOf("shop.cupcakesaregreat.com") > -1) {
	// ga('create', 'UA-1234567-5', 'auto');
	ga('create', 'UA-1234567-5', 'auto', {'allowLinker': true});
	ga('require', 'linker');
	ga('linker:autoLink', ['cupcakesaregreat.com', 'shop.cupcakesaregreat.com', 'netsuite.com']);
	ga('send', 'pageview');
	// console.log("US Shopping Cart");
} 
// if the user is in the Canadian shopping cart
else {
	// ga('create', 'UA-1234567-25', 'auto');
	ga('create', 'UA-1234567-25', 'auto', {'allowLinker': true});
	ga('require', 'linker');
	ga('linker:autoLink', ['cupcakesaregreat.com/ca/', 'shop.cupcakesaregreat.com/ca/', 'netsuite.com']);
	ga('send', 'pageview');
	// console.log("Canadian Shopping Cart");
}
</script>

 

On this order confirmation page, we also do all of the GA ecommerce as well as AdWords conversions.

 

I have to assume since we're not getting stuff like Campaigns that I am doing something wrong, but I can't quite figure out why. I have tried using the Chrome GA Debugger extension, but I'm not familiar enough with GA to understand what's wrong.

 

I know this is a lot to look at, so thank you very much in advance to anyone offering advice/help. Thank you.

 

1 Expert replyverified_user

Re: Cross domain tracking issues (campaigns, referral type, source/med

Top Contributor
# 2
Top Contributor
Hi,

long readSmiley Happy

Before we get into details - the second code is something to consider as an issue:
1. Is the classic GA code there needed?
2. Do the classic and universal code send data to the same property (tracking id)?

Kind regards,
Zorin
Web analyst @ escapestudio.net

Re: Cross domain tracking issues (campaigns, referral type, source/med

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Zorin,

Thank you for responding, yes, it really was quite a long read.

1. I noticed that the classic GA was there as well and considering the universal is called shortly after in the code I don't believe it needs to be. Just to be sure, classic GA is "/ga.j"s file and universal is "/analytics.js", right?

2. Yes, both send the data to the same property/tracking ID.

Re: Cross domain tracking issues (campaigns, referral type, source/med

Top Contributor
# 4
Top Contributor
Hi Anthony,

1. Remove that code as it duplicates hits and does unwanted things to traffic attribution in GA (in this setup). Yes, classic is ga.js.

2. See #1Smiley Happy

3. Referral exclusion list in your case only needs to exclude 2 domains netsuite.com and cupcakes.com

4. When you cross domains do you see _ga parameter added to the URL?

5. I do not see the IF statement for us and ca trackers in 2nd code and this one and the checkout one should be based on document.referrer / cookie respectively as I see it now

Hope it helps!

Kind regards,
Zorin
Web analyst @ escapestudio.net

Re: Cross domain tracking issues (campaigns, referral type, source/med

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Thank you again for your reply Zorin.

1. I removed the duplicate code and only Universal Analytics code should be throughout the shopping cart.

3. If extra domains are added to the referral exclusion list, will that be an issue? I am going to remove those I don't need, but I'm just wondering if additional (and unnecessary) domains in this list cause issues.

4. Yes, when I get to the shopping cart a _ga parameter appears in the URL. Our "add to cart" buttons on cupcakesaregreat.com have "&_ga=1.123456789.123456789.123456789" for the link.

5. I left something out my long explanation above, but this is OK. The correct tracking ID gets set for both US and Canadian sites.

Re: Cross domain tracking issues (campaigns, referral type, source/med

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Also,

 

Using the Google Analytics Debugger Chrome extension I found that the Campaign name changes from "Chocolate_Flavor" (which for example would come from a Google.com search for our product) to "(referral)" once at the shopping cart page.

 

I tried adding images to this post, but I keep getting an error with the WYSYWIG.

Re: Cross domain tracking issues (campaigns, referral type, source/med

Top Contributor
# 7
Top Contributor
Hi Anthony,

the main thing is that the clinetId remains the same when you cross domains which can be inspected in Chrome Console with GA debugger.

You may even opt to use:
ga('create', 'UA-XXXX-Y', 'auto', {'legacyHistoryImport': false});
Which will not allow GA to use cookie info from the old ga.js cookies which seems to be the case with your current setup.

Kind regards,
Zorin
Web analyst @ escapestudio.net