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

Experiment code missing the cookie domain name declared in tracking code

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

Hello,

 

I am launching my first experiment in GA and running into an issue with a cookie.  I get the error below when I validate my experiment code:

"Original:
Experiment code missing the cookie domain name declared in tracking code:line:373, column:22.
Variation 1:
Experiment code missing the cookie domain name declared in tracking code:line:373, column:22."
 
I know close to nothing about coding, so I don't know where to start to fix this.  I've searched around but can't find an answer.  Any thoughts?
 
-Brad
 
Here is my 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-74430184-1', 'auto');
ga('send', 'pageview');

</script>
 
Here is my Experiment code:
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='117596845-0',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 -->
1 ACCEPTED SOLUTION

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

Re: Experiment code missing the cookie domain name declared in tracking code

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
After much research, trial, and error, I found a solution!

I added the following above the experiment code:

&lt;script&gt;
_udn = "none"
&lt;/script&gt;

Issue solved.

View solution in original post

Re: Experiment code missing the cookie domain name declared in tracking code

[ Edited ]
A T
Participant ✭ ✭ ✭
# 2
A T
Participant ✭ ✭ ✭

you might have multiple tracking code on pages.

you need: https://support.google.com/analytics/answer/2364634?hl=en

Re: Experiment code missing the cookie domain name declared in tracking code

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Does anything go wrong if it's not corrected?
Marked as Best Answer.
Solution
Accepted by topic author Duck H
March 2016

Re: Experiment code missing the cookie domain name declared in tracking code

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
After much research, trial, and error, I found a solution!

I added the following above the experiment code:

&lt;script&gt;
_udn = "none"
&lt;/script&gt;

Issue solved.

Experiment code missing the cookie domain name declared in tracking code

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Thanks for taking the time to post this! Worked for me too.  I'm thinking we may be turning off the function where if they leave our site and come back, they'll be served the same page, but I'm ok with this.

Experiment code missing the cookie domain name declared in tracking code

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Thank you!! this worked for me too!