So I have two sites for a client, we'll say www.main.com is their main website and www.signup.com is a site where the user signs up for a certain service.
I recently switched signup.com over to universal analytics so that we could implement cross-domain tracking via the autolink plugin.
I used this article to help me set up the code on each domain.
Here is what I have on main.com:
<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-11865301-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['signup.com'] );
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
NOTE: I'm not sure what 'displayfeatures' is. I was told that a 3rd party vendor had to customize the code at one point and that I shouldn't remove anything.
And here is what I have on signup.com:
<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-11865301-1', 'auto'), {'allowLinker': true};
ga('require', 'linker');
ga('linker:autoLink', ['main.com'] );
ga('send', 'pageview');
</script>
I also have both domains listed in my Referral Exclusion List so that we don't see main.com as referrals for the signup goal.
What's happening now though, is that for almost all of our conversions, the source/medium is showing as (direct)/(none) and the referral path is showing as (not set). We cannot figure out why.
At the time of this posting there are 14 goal conversions for the day. All of them are reporting a referral path of (not set) and 13 of them are reporting a source/medium of (direct)/(none). There is one conversion that has it's source/medium listed as bing/organic, if that is any kind of clue.
I'm not finding a lot of results on the subject in my googling so this is my last resort. Any help would be appreciated.
UPDATE: So I've been researching this heavily for the past 24 hours and have found out more information.
The (direct) or (not set) referral sources are coming from main.com. The reason they are listed as direct or not set referrals is because we have main.com listed in the referral exclusion list. When I turned it off these referrals started coming is as main.com.
It's starting to look more and more like there is no way to take the original referrer from main.com and carry it over to signup.com.
Can anyone confirm or deny this theory?
When you link domains for cross-domain tracking, they should all be included in the autoLink.
ga('linker:autoLink', ['signup.com', 'main.com'] );
Related
This is a two part question:
1) Is my new Google Analytics tracking code correct?
2) With the new code, I noticed a HUGE drop in reported sessions. Is this because the tracking code is more accurate or because my tracking code is wrong.
My Domains (example):
www.domain.org
abc.domain.org
cde.domain.org
www.domain.info
abc.domain.info
cde.domain.info
My OLD Google Analytics Tracking Code:
<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-99999999-9', 'domain.org');
ga('send', 'pageview');
</script>
My NEW Google Analytics Tracking Code:
<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-99999999-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', [/^domain\.(org|info)$/]);
</script>
Note: I see my second script doesn't have "ga('send', 'pageview');" could that be the reason for the HUGE drop in reported sessions?
Thanks in advance
Answer to your second question, a huge YES! If you don't have a pageview, then you don't have a way to indicate the start of a session.
Your setup looks correct - just might want to check to see if the auto-link domains accepts regex as I have a feeling it doesn't, ie.:
ga('linker:autoLink', [domain.org, domain.info]);
You might have to list them all out.
Don't forget to add your different domains to the referral exclusion list.
New code is better.
You have drop in number of sessions because now your sessions count in a right way.
Now if user jump from domain.org to domain.info it will be 1 session.
With old code it will be 2 sessions.
I've always used one Javascript GA tracking script on my page, for www.example.com version of my website. It used the property ID UA-XXXXXX-1. However, I read somewhere that pages viewed on your example.com domain (without www.) won't get tracked properly this way. So I added a second property, without the www. It had the property ID UA-XXXXXX-14.
Now, I'm seeing a significant rise in my page views (more than double, actually) for the stats of my UA-XXXXXX-1 property, but not in my sessions. Does this mean that Google Analytics is tracking page views twice? And if so, how is this possible, since I'm just looking at the stats for UA-XXXXXX-1?
EDIT: This is the code I'm using:
<script type="text/javascript">
(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-XXXXXX-1', 'auto');
ga('send', 'pageview');
</script>
<script type="text/javascript">
(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-XXXXXX-14', 'auto');
ga('send', 'pageview');
</script>
However, I read somewhere that pages viewed on your example.com domain (without www.) won't get tracked properly this way.
This is wrong. GA in its default configuration will track properly, even if www.example.com is technically a subdomain of example.com. Plus changing the domain in your account configuration will not actually affect data collection.
Does this mean that Google Analytics is tracking page views twice?
Yes, probably. However this is not related to tracking with to properties unless there is a problem with your configuration. Most likely you are accidentaly tracking twice to the same property.
If I had to take a wild guess I'd say you are doing this:
ga('create', 'UA-XXXXXX-2', 'auto');
ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');
ga('send', 'pageview');
when you should be doing this:
ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');
ga('create', 'UA-XXXXXX-2', 'auto');
ga('send', 'pageview');
i.e. to send the pageview before you create your second tracker (because the second one will overwrite the first).
Alternatively you could use named trackers:
ga('create', ''UA-XXXXXX-1', 'auto', {'name': 'trackerOne'});
ga('create', ''UA-XXXXXX-2', 'auto', {'name': 'trackerTwo'});
ga('trackerOne.send', 'pageview');
ga('trackerTwo.send', 'pageview');
Since the tracker objects are called by name you can be sure that your calls always go to the correct tracker, no matter in which order the code is called in your page.
However if that is the problem you should not see data in your second account. In that case you need to share your actual tracking code.
I've set up a rollup account for several off my other domains (Like; mydomain.com, mydomain.org, mydomain.net)
When I look at the rollup account I can see the reports but they all come from "/" instead of "mydomain.org" or "mydomain.net", is it possible to see this somehow? or track it?
Code Im running on the subsites:
<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-xxxxxxxx-1', 'auto');
//roll up account
ga('create', 'UA-xxxxxxxx-2', {'name':'rollupProperty'});
ga('send', 'pageview');
ga('rollupProperty.send','pageview');
</script>
I had similar case for one of my clients,
Google Analytics by default shows only page pathe (like /mypage.php instead of mydomain.com/mypage.php, mydomain.org/mypage.php, etc.).
If you want just temporary solution, go to "Behavior -> Site Content -> All Pages" in GA reports and choose "Hostname" as secondary dimension:
If you want always see hostname in your GA reports, then you should create Advanced filter for rollup GA property:
This filter may allow you to extract Hostname(mydomain.org) and Ruquest URI(/mypage.php) and rewrite Request URI by combination "mydomain.org/mypage.php" in GA reports.
Recommend you to test this approach.
I am just looking for some help setting up a single view of all the sites we have. I can find lots of help for the old analytics tracking code but not for the new universal analytics.
I've got 5 sites each with their own tracking code in place but i'd like to create a roll up account that allows me to look at an overview of all the sites in a single view. Just wondering what i need to add to the code to do this?
It's currently;
<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-XXXX', 'auto');
ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
And I would just like to know what i need to add in to be able to include the numbers in a roll up account too? I think it's possible to simply edit this code with the UA of the roll up account but I'm not sure of the correct way to format this.
Any help would be appreciated,
Thanks
Roxi
It works rather like it did with asynchronous analytics, only you pass the name of the tracker in the (optional) configuration object:
ga('create', 'UA-XXXXX-X', {
'name': 'firstTracker',
});
ga('create', 'UA-XXXXX-Y', {
'name': 'secondTracker',
});
ga('firstTracker.send', 'pageview');
ga('secondTracker.send', 'pageview');
Any other options (e.g cookie domain, which is the third parameter if you don't use a configuration object) are set as key-value pairs in the configuration object. You find this in the documentation under Advanced Configuration.
This is my first question on Stackoverflow. So apologies if I make a mistake...
The challenge: I have a website (main.com), a sub-domain (sub.main.com) and 10 websites that send traffic, back and forth, to the main site and the sub domain. Let's call these sites site01.com, site02.com, site03.com,...,site10.com.
My question: How do I implement Universal Tag so I can do cross-domain tracking between main.com, sub.main.com and site01.com, site02.com, site03.com,...,site10.com.
I found instructions on how to do cross domain tracking for two sites. For example, on the main domain I will add the following code:
**<!-- Universal Analytics -->
<script type="text/javascript">
(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-XXXXXXXXX-X', 'main.com', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['site01.com']);
ga('send', 'pageview');
</script>**
And on site01.com, I will add the code below:
**<!-- Universal Analytics -->
<script type="text/javascript">
(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-XXXXXXXX-X', 'site01.com',{'allowLinker': true});
ga('send', 'pageview');
</script>**
I don't know how to modify the code to include all 10 sites (site01.com, site02.com, site03.com,...,site10.com as part of the cross domain tracking.
Also, in relation to sub-domain tracking, I am guessing that the above code will also capture data from the sub-domain site (sub.main.com) with no issues.
Any help will be greatly appreciated.
Stratos.
You need to add the linker plugin to all of your sites, otherwise you only track visitors starting at the main domain and from there navigating to your subsites. The other way around (originates from site01.com and browses to your main site) would generate a new clientId.
Example (same for all of your sites):
ga('create', 'UA-XXXXXXX-X', 'auto', {
'allowLinker': true
});
ga('send', 'pageview');
// Load the linker plugin and define
// which domains to autoLink.
ga('require', 'linker');
// NOTE: add all your sites here. you can include the
// the site the code is at too if you want to use the
// same array of sites for all of your sites (ie,
// include this from some shared file)
ga('linker:autoLink', ['main.com', 'site01.com', 'site02.com', 'site03.com']);
Use for example the Google Analytics Debugger extension to Chrome to verify that you get the same clientId.
NOTE: You need to click on an achor-link to the other sites for the autoLinker to work, just typing in the URL in your browser won't work.
For implementing this on forms too pass true as a fourth parameter to the ga('linker:autoLink')-call above (ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autoforms).