Analytics
2.2K members online now
2.2K 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

Self referrals during Analytics content experiments - ga.js

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

We are running pages with cross domain tracking. Visitors browse on one page and then the conversion funnel is handled by a third party. The third party requires us to use the old ga.js. We noticed when running A/B tests the visitor origins for sessions with conversions seem to be all messed up. Some conversions carry natural channels, but the majority only shows a self referral as visitor origin. The analytics script is untouched for the test and looks something like below. Are we overwriting cookies or what is happening here and more important what is the solution?

 

	<script type="text/javascript">		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-xxxxxx']);
		_gaq.push(['_setDomainName', 'domain.com']);
		_gaq.push(['_setAllowLinker', true]);
		_gaq.push(['_setAllowAnchor', true]);
		_gaq.push(['_gat._forceSSL']);
		_gaq.push(['_gat._anonymizeIp']);
		_gaq.push(['_trackPageview']);
		

		(function () {
			var ga = document.createElement('script');
			ga.type = 'text/javascript';
			ga.async = true;
			ga.src=('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
			var s = document.getElementsByTagName('script')[0];
			s.parentNode.insertBefore(ga, s);
		})();
	</script>

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Daniel K
November 2015

Re: Self referrals during Analytics content experiments - ga.js

Top Contributor
# 8
Top Contributor
So it is the variation that craps out then... Oh yeah and the utm variables are for ga.js and the _ga is for universal (sorry about mixing in that one).

When moving to conversion funnel from variation (any way you make the transition) is it done in the same way than in the original? I suspect that some code related to cross domain tracking is missing. Do you have any debugging tools at your disposal, they might give you a hint if some JavaScript is failing...
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

View solution in original post

Re: Self referrals during Analytics content experiments - ga.js

Top Contributor
# 2
Top Contributor
Hi,

I haven't run many A/B tests but this came into my mind:
GA relies URL parameters when transferring the session from domain to another.
If your A/B test tool replaces or removes those GA URL parameters it will break cross-domain tracking.
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: Self referrals during Analytics content experiments - ga.js

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
I am using GA content experiments and would expect this not to be an issue as there is no thir party involved on that end.

Re: Self referrals during Analytics content experiments - ga.js

Top Contributor
# 4
Top Contributor
I hate just drop a link but I have to fly:
https://support.google.com/analytics/answer/2658141

Have you done these minor changes that this article refers to?
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: Self referrals during Analytics content experiments - ga.js

[ Edited ]
Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Yes i implemented the additional lines:


<script>
_udn = "example.com";
</script>


The other modifications do not apply, as far as I can see. Without those lines the test could not be started.

Re: Self referrals during Analytics content experiments - ga.js

Top Contributor
# 6
Top Contributor

Both your domain and the conversion funnel are using the same GA code with dc.js?
Can you see something like this in the URL when you move to your conversion funnel: _ga=1.182119591.1441315536.1362115890410?
Does this happen in both cases, in original and in variation?
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: Self referrals during Analytics content experiments - ga.js

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Yes both use the same code.
The original adds those kind of parameters and it always used to:

__utmx=246967508.CEaQ-23HT6S2rE6yB0RVkQ$87494195-5:0&__utmv=-&__utmz=246967508.1446811032.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)&__utmk=266897165&__utma=246967508.175953349.1446811032.1446811032.1446811032.1&__utmc=246967508&__utmb=246967508.4.9.1446811075740

The variation does not add any utm or ga parameters.
Marked as Best Answer.
Solution
Accepted by topic author Daniel K
November 2015

Re: Self referrals during Analytics content experiments - ga.js

Top Contributor
# 8
Top Contributor
So it is the variation that craps out then... Oh yeah and the utm variables are for ga.js and the _ga is for universal (sorry about mixing in that one).

When moving to conversion funnel from variation (any way you make the transition) is it done in the same way than in the original? I suspect that some code related to cross domain tracking is missing. Do you have any debugging tools at your disposal, they might give you a hint if some JavaScript is failing...
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: Self referrals during Analytics content experiments - ga.js

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Well, you hinted me in the right direction. I found the issue.

The original page uses form submits to link to the conversion funnel. The forms correclty trigger an onsubmit event - something like this:

onsubmit="_gaq.push(['_linkByPost', this]);"

 

The variation just forced the same event, but as it is not a form, but a button it needs to be adjusted to:

 

onclick="_gaq.push(['_link', 'http://example.com/test.html']); return false;"

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory

Re: Self referrals during Analytics content experiments - ga.js

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

Hello I search a way to add a new Tracker into my analytics. This discussion seems to be the nearest based on my needs.

 

The website where I need to track the activity is based on 1 page and AJAX CALL to generate content.

Consequence Google track 1 page my Default.htm 
The Idea is to be able to simulate on each ajax call result the page I want to track.

The current page value is stocked into MyCustomPageName variable.

 

I declared this on top on my code

 

var MyCustomPageName = $("CustomPage").value;
var _gaq = _gaq || []; _gaq.push(function() { var pageTracker = _gat._createTracker('UA-XXXXXXXX', 'AjaxPage'); var link = $("CustomPage"); link.href = pageTracker._getLinkerUrl(''+MyCustomPageName+''); }); _gaq.push(['_gat._forceSSL']); _gaq.push(['AjaxPage._trackPageview']);

 

 

and the classic code is at the bottom just before the body closure.

(It's not the original code because I due to change this a.src=''+g; to make it work behind a DLL)

 

 

 

(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','script/analytics.js','ga');
ga('create', 'UA-XXXXXXX', 'auto');
ga('send', 'pageview');

 

So on each load after ajax return I want to inject into my personal Tracker the name of the page.

link.href = pageTracker._getLinkerUrl(''+MyCustomPageName+'');

I search some other function rather than getLinkerUrl but noting into https://support.google.com/analytics/ or into https://developers.google.com/analytics/devguides/collection/ are available.