Search
Clear search
Close search
Google apps
Main menu

Cookie customizations in Experiments

This information applies only to the ga.js and the urchin.js tracking methods.

Any customization to the cookie domain, cookie path, or cookie hash has to appear in both your Analytics tracking code and in your experiment code when they are used on the same page. Follow these guidelines:

Modification Usage Asynchronous JavaScript Example Traditional GA.js Example Urchin.js Example
Cookie Domain Sets the domain in which Analytics cookies are set. The default is the domain of the current web page (minus any sub-domain) _gaq.push(['_setDomainName', '.foo.com']); Tracker.setDomainName(".foo.com"); _udn = ".foo.com";
Cookie Path Sets the path in which the Analytics cookies are set. The default is "/". _gaq.push(['_setCookiePath', '/bif/a']); Tracker.setCookiePath("/bif/a"); _utcp = "/bif/a";
Cookie Hash Determines whether Analytics cookies are prefixed with a hashcode that is specific to the cookie domain. The default is "on". _gaq.push(['_setAllowHash', false]); Tracker.setAllowHash(false); _uhash = "off";

To perform the necessary customizations to your experiment script, also add the corresponding urchin.js customizations immediately before the experiment script. (Note: The experiment script needs urchin.js-style customization, regardless of whether you are using ga.js or urchin.js modifications with your tracking scripts.) For example:

<script>
 _udn = ".foo.com";
 _utcp = "/bif/a";
</script>

<script>
 ... Contents of the experiment script ...
</script>
Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.