Analytics
3.8K members online now
3.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

Content Experiment - Error: No Google Analytics tracking code found (When tracking code exists)

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi Google Analytics Community,

 

We are currently trying to conduct an A/B Content Experiment. The directions have been followed to the T but we are not able to get our experiment to validate.

 

The errors we receive are:

Original:
No Google Analytics tracking code found.
Variant 1:
No Google Analytics tracking code found.
 
The issue is, we do have our Analytics code installed. To troubleshoot this, I have created a blank HTML5 doc with nothing in it but our Experiment code at the top of the documents head and our GA tracking code at the bottom of the documents head. There is also an h1 in each variant, one is blue and the other red.
 
Here is our experiment code:
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='14488049-7',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
</script><script>utmx('url','A/B');</script>
<!-- End of Google Analytics Content Experiment code -->
 
Here is a portion of our tracking code:
// START Standard GA Call 
var _gaq = _gaq || [];
_gaq.push(['_setAccount', gaAccount]);
_gaq.push(['_setDomainName', gaDomain]);
_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);
})();
 
 Any suggestions would be muchly appreciated.
 

Content Experiment - Error: No Google Analytics tracking code found (When tracking code exists)

[ Edited ]
Follower ✭ ✭ ✭
# 2
Follower ✭ ✭ ✭

Well the first easiest possible issue I see is that your tracking code is not wrapped in "<script>, </script>" as the content experiment is. 

Aside from that if you know all the code is correct - it may take one to two days until you start seeing reported data.

Content Experiment - Error: No Google Analytics tracking code found (When tracking code exists)

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thanks Adam.

 

I took the JS code from inside a JS file, other than that I do know that the code is correct. Unfortunately today is day four and still no data. Could there be a conflict from the version of Google Analytics that I am using?

 

Content Experiment - Error: No Google Analytics tracking code found (When tracking code exists)

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Does anyone know if Content Experiments will work with async Google Analytics?