Analytics
2.8K members online now
2.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 suggestion

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have 2 website e.g.

  1. example.com (Normal website) (GA Property 1)
  2. shop.example.com (Ecommerce website) (GA Property 2 with Ecommerce tracking enabled)

 

Currently I setup a new (GA Property 3 with Ecommerce tracking enabled) cross domain tracking using Google Tag Manager using Auto Link Domains approach

 

However, my Ecommerce tracking result is not shown in the GA Property 3.

 

I have duplicate the tag as shown below in the ecommerce page but it is not working.

Please advise if there is any issue by using this approach?

 

Or I should not use Property 3 for cross domain tracking purposes, I should use shop.example.com Property 2 code and install in example.com Property 1? Any concerns on the latter approach e.g. should create a new view so that previous data is not affected?

 

Thanks.

 

       <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-Property-2', 'auto');
            ga('send', 'pageview');
        </script>
        <script>
            var order = <{$ga}>;
            var items = <{$ga_item}>;

            ga('require', 'ecommerce');
            ga('ecommerce:addTransaction', {
                'id': order.id,                     // Transaction ID. Required.
                'affiliation': order.affiliation,   // Affiliation or store name.
                'revenue': order.revenue,               // Grand Total.
                'shipping': order.shipping,                  // Shipping.
                'tax': order.tax,                  // Tax.
                'currency': order.currency
            });

            items.each(function (v, k) {
                ga('ecommerce:addItem', {
                    'id': v.id,
                    'name': v.name,
                    'sku': v.sku,
                    'category': v.category,
                    'price': v.price,
                    'quantity': v.quantity
                });
            });
            ga('ecommerce:send');

            new Request({
                url: "<{link app=b2c ctl=site_paycenter act=ga}>",
                method: "post",
                data&colon; "order_id=" + <{$payment.order_id}>
            }).send();

        </script>
		
       <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', 'Property-3', 'auto');
            ga('send', 'pageview');
        </script>
        <script>
            var order = <{$ga}>;
            var items = <{$ga_item}>;

            ga('require', 'ecommerce');
            ga('ecommerce:addTransaction', {
                'id': order.id,                     // Transaction ID. Required.
                'affiliation': order.affiliation,   // Affiliation or store name.
                'revenue': order.revenue,               // Grand Total.
                'shipping': order.shipping,                  // Shipping.
                'tax': order.tax,                  // Tax.
                'currency': order.currency
            });

            items.each(function (v, k) {
                ga('ecommerce:addItem', {
                    'id': v.id,
                    'name': v.name,
                    'sku': v.sku,
                    'category': v.category,
                    'price': v.price,
                    'quantity': v.quantity
                });
            });
            ga('ecommerce:send');

            new Request({
                url: "<{link app=b2c ctl=site_paycenter act=ga}>",
                method: "post",
                data&colon; "order_id=" + <{$payment.order_id}>
            }).send();

        </script>		

 

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author CPL_Test
March 2016

Re: Cross domain tracking suggestion

Top Contributor
# 4
Top Contributor
I haven't heard of a 3rd property specifically for x-domain tracking, but I suppose it is possible.

If I were you, I would just have the 1 property and multiple views.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

View solution in original post

Re: Cross domain tracking suggestion

Top Contributor
# 2
Top Contributor
Hi CPL_Test,

A couple of things to note here. What you're describing isn't cross-domain tracking, as everything is happening on the same domain, example.com. If your intention is to track visits seamlessly (ie. without creating a new session when go from example.com to shop.example.com, you just need to set the cookie domain to "auto" when you create your tracking object. Also you would need to have "example.com" in the referral exclusion list. Second thing to note here, is that you are creating two tracking objects, but you are not distinguishing them . When you create multiple trackers on the same page, you need to give them a name. Then whenever you make a function call to one of the GA methods (ie. "send", "require", etc.), you also need to append the tracker name. For example:

ga('tracker1.send', 'pageview');
ga('tracker2.send', 'pageview');

Hope you get on the right track.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Cross domain tracking suggestion

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Nicky,

 

Thanks for your reply.

 

Our intention is to track the same session and conversion between these two sites.

 

Based on our current scenario, what is the best practice or recommend approach? Use 1 GA Property for the 2 sites or use 3 GA Properties?

 

Meantime, I will look into the multiple tracker solution that you have advised.

 

Thanks.

 

 

Marked as Best Answer.
Solution
Accepted by topic author CPL_Test
March 2016

Re: Cross domain tracking suggestion

Top Contributor
# 4
Top Contributor
I haven't heard of a 3rd property specifically for x-domain tracking, but I suppose it is possible.

If I were you, I would just have the 1 property and multiple views.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Cross domain tracking suggestion

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
I will use 1 property for multiple view approach. Thanks for the suggestions.