Classic to Universal Google Analytics Migration - google-analytics

I want to migrate classic to Universal Google Analytics tracking, I want to track content and events only for the live domain (not staging):
Currently, I have used method for classic version:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'TRACKING ID']);
_gaq.push(['_setDomainName', 'mydomain.com']);
_gaq.push(['_trackPageview']);
I have tried below method but it is not working:
ga('create', 'TRACKING ID', {'cookieDomain': '.mydomain.com'});
also tried below method:
ga('create', 'TRACKING ID', 'auto', {'legacyCookieDomain': 'mydomain.com'});
Can you please help on this?

I you are using Adwords & Doubleclick you should consider gtag.js instead of Universal
Using '.domain.com' or 'auto' on create event generates the same result. Check Google Analytics cookieDomain documentation. This option is used in order to share the cookie between subdomains.
If you want to avoid collecting data from other domains or subdomains, use a filter (include only your domain).

Related

How to configure multiple tracking code of Google analytics

I have created two accounts (www.websiteUrl1.com and www.websiteUrl2.com) in my Google Analytics account.
Actually www.websiteUrl1.com and www.websiteUrl2.com shares the same code base and deployed on single server and single portal.
Now we want to track traffic of www.websiteUrl1.com and www.websiteUrl2.com separately. Each this account has their own tracking code and not sure how can we add another tracking code there.
This is how we have configured tracking code in our website as
<!-- Global site tag (gtag.js) - Google Analytics. www.websiteUrl1.com -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXXXX-1');
</script>
Can you please guide how can we configure another urls (www.websiteUrl2.com) tracking code?
I would switch the analytics code server side based on the referring domain. If the domain is www.websiteUrl1.com write out tracking code 1, if it is www.websiteUrl2.com write out tracking code 2.

Cross Domain Tracking script into Google Tag Manager settings?

I am trying to set up my website to have cross domain tracking with the online store Gumroad.com, inside my Google Analytics. So that I can follow the user events from one site onto the next.
Gumroad has instructions at this link, but they are in the format of a script to be pasted into the site.
I use Tag Manager and am wanting to input these parameters into my Google Analytics Settings variable (which is how Google recommends doing Cross domain tracking with Tag Manager)
I'll attach the script that they provided, as well as my Google Analytics Settings variable in Tag Manager. If anyone knows how to set up the rest of the parameters that would be greatly appreciated!
Script:
<script>
// mystorefront.com is your site's domain.
ga('create', 'UA-XXXXX-Y', 'mystorefront.com;, {'name': 'sampleTracker', 'allowLinker': true, ';cookieDomain': 'mystorefront.com'});
ga('sampleTracker.require', 'linker');
ga('sampleTracker.linker:autoLink', ['mystorefront.com']);
ga('sampleTracker.send', 'pageview');
</script>
My Tag Manager (Google Analytics Settings variable) setup so far:
[]
Set domains in list without protocol.
It also does not make sense that you use cookieDomain as Field to set when it is already defined in the field below the tracking ID.

Universal Analytics - Cross Domain Tracking on multiple eCommerce sites with shared checkout

I manage multiple e-commerce sites that all share the same checkout process but have individual google-analytics accounts. Under the old google analytics for cross-domain tracking we used:
['_setDomainName', 'none']
When on the SSL checkout part of the process.
Under universal analytics I understand you can use linker plugin for cross-domain tracking but I don't see an equivalent to the 'none' configuration above. What is the correct way to achieve this?
I hope I understand your problem correctly. The best explanation is on the Google Documentation page but I'll try to make a summary.
The _setDomainName configuration, on ga.js, sets the domain name for the Google Analytics cookies:
_gaq.push(['_setDomainName', 'mywebsite.com']);
On analytics.js, the new way to do this is:
ga('create', 'UA-XXXXX-Y', {
cookieDomain: 'mywebsite.com'
});
And if you'd like to use the legacy cookies (from ga.js), you also should populate the legacyCookieDomain setting:
ga('create', 'UA-XXXXX-Y', {
cookieDomain: 'mywebsite.com',
legacyCookieDomain: 'mywebsite.com'
});
There are two ways to have an equivalent to the 'none' configuration. The first one is:
ga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
But Google suggests to use this solution to set cookies on localhost. The second solution is sending data directly to Google Analytics without the use of cookies.
ga('create', 'UA-XXXX-Y', {
'storage': 'none',
'clientId': '35009a79-1a05-49d7-b876-2b884d0f825b'
});
Here you'll have to supply your own clientId parameter.

Google Analytics Cross-Domain Conversion Tracking and Attribution to AdWords Campaign

Background
We have a number of websites that we maintain and we have Google AdWords Campaigns running to drive traffic to these sites.
For Example:
www.example1.co.uk
www.example2.co.uk
www.example3.co.uk
After browsing these sites, a customer will be redirected to our E-Commerce platform if they decide to make a purchase (this is where the conversion happens):
www.example-checkout.com
Current Google Analytics Setup
Our current Google Analytics Setup looks like this:
www.example1.co.uk, www.example2.co.uk, www.example3.co.uk
ga('create', 'UA-12345678-1', 'auto', {'name': 'globalTracker'});
ga('globalTracker.send', 'pageview');
ga('globalTracker.require', 'linker');
ga('globalTracker.linker:autoLink', ['example-checkout.com'], true);
www.example-checkout.com
All Pages
ga('create', 'UA-12345678-1', 'auto', {'allowLinker': true, 'name' : 'globalTracker'});
ga('globalTracker.send', 'pageview');
Checkout Page Only
The checkout/confirmation/thank you page contains additional calls to load the Google Analytics E-Commerce plugin and post the details of the transaction that has occurred.
ga('create', 'UA-12345678-1', 'auto', {'allowLinker': true, 'name' : 'globalTracker'});
ga('globalTracker.send', 'pageview');
ga('globalTracker.require', 'ecommerce', 'ecommerce.js');
ga('globalTracker.ecommerce:addTransaction', {
'id': '${transactionID}',
'affiliation': '${affiliation}',
'revenue': '${revenue}',
'shipping': '${shipping}',
'tax': '${tax}'
});
ga('globalTracker.ecommerce:send');
What Works
The E-Commerce tracking code appears to work and conversions are recorded. In Google Analytics we can see that we received traffic/clicks from our AdWords campaigns which suggests that the _ga cookie is being correctly passed cross-domain from www.example1.co.uk to www.example-checkout.com (in fact I have verified this using the Chrome Developer Tools / Google Analytics Debugger Plugin).
Problem
The problem is that the conversions are never attributed to the AdWords Campaign & AdGroup. The source of the conversion is always a referral (E.g. from www.example1.co.uk).
What am I missing? I want to see the conversions attributed to the AdWords campaign. I.e. in the "Acquisition -> Campaigns" section of Google Analytics.
Any pointers are greatly appreciated.
You do not mention that you use any decorator functions (i.e. functions that add the ga parameter to outgoing links, forms etc.) and allowLinker does not do this automatically. So it should be not possible that cross domain tracking works at all (i.e. both domains will be tracked but on changing the domain the user will start a new tracking session). (UPDATE: Sorry, I did not see the autolinker plugin in the code, so ignore this paragraph).
Plus you need to add both domains to the referrer exclusion list in the property settings (this will remove the referrer no matter what, so make sure that the client id is passed on before you do that).
Unless you have used decorators without saying so in the question this is most likely your problem. Look into the outgoing urls if the ga parameter is appended when switching domains and make sure that the ga code on the other domain does actually receive the parameter (i.e. if there are redirects make sure they retain the parameter).

Missing Analytics statistics for subdomain

I track a main domain and subdomain in one Analytics property. I have a shared profile and also subdomain-specific profiles using the Hostname filter.
I prepend /blog to the URLs on blog.domain.com because it gives good and readable reports on the shared profile (compared to displaying the full URL).
www.domain.com is http-only, blog.domain.com is https-only.
Tracking code on www.domain.com:
_gaq.push(['_setAccount', 'UA-XXXX-1']);
_gaq.push(['_setDomainName', '.domain.com']);
_gaq.push(['_trackPageview']);
Tracking code on blog.domain.com:
_gaq.push(['_setAccount', 'UA-XXXX-1']);
_gaq.push(['_setDomainName', '.domain.com']);
_gaq.push(['_trackPageview', '/blog/article-title');
Problem is, only about 2 out of 15 daily pageviews from the blog show up in the reports.
Using the Chrome GA Debugger I can see that the tracking beacon is sent. The GA live view also seem to show all these pageviews. There are only one set of GA cookies (.domain.com), and I can see the the counters in the cookie increment on each pageview.
I also have a _trackEvent on the blog that have incomplete statistics. But for some reason, my eCommerce tracking seems to be complete.
Any reason that tracking pageviews and events for blog.domain.com should not work in the above case?

Resources