Last Updated: 20 Oct 2023
|
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
marketing-tech:google-analytics:setvar-and-the-zero-bounce-rate-bug [Jan 28, 2009 08:38 AM] dordal |
marketing-tech:google-analytics:setvar-and-the-zero-bounce-rate-bug [Oct 20, 2023 08:36 PM] 135.181.114.235 old revision restored (Oct 20, 2023 12:29 PM) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | = _setVar() and the zero bounce rate bug in Google Analytics = | ||
+ | |||
+ | ** UPDATE - Jan 27, 2009: Google has reportedly fixed the bug in GA that was causing the problem described on this page. Thus the fix is no longer necessary, but I will leave it here for historical reference. ** | ||
+ | |||
+ | Google Analytics has a '' | ||
+ | |||
+ | Unfortunately, | ||
+ | |||
+ | Conveniently, | ||
+ | |||
+ | This lends itself to a nice solution to the problem: we'll simply check if the value we want to call '' | ||
+ | |||
+ | <code javascript> | ||
+ | /* | ||
+ | * getCookie(): | ||
+ | * From http:// | ||
+ | * | ||
+ | */ | ||
+ | function getCookie(name) { | ||
+ | var dc = document.cookie; | ||
+ | var prefix = name + " | ||
+ | var begin = dc.indexOf("; | ||
+ | if (begin == -1) { | ||
+ | begin = dc.indexOf(prefix); | ||
+ | if (begin != 0) return null; | ||
+ | } else | ||
+ | begin += 2; | ||
+ | var end = document.cookie.indexOf(";", | ||
+ | if (end == -1) | ||
+ | end = dc.length; | ||
+ | return unescape(dc.substring(begin + prefix.length, | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | * utmvCookieCheck(): | ||
+ | * that value is already set. Return true if so, false otherwise. | ||
+ | * | ||
+ | */ | ||
+ | function utmvCookieCheck(value) { | ||
+ | var utmvCookie = getCookie(" | ||
+ | |||
+ | if (utmvCookie == null) | ||
+ | return false; | ||
+ | |||
+ | // get rid of the Google' | ||
+ | // GA cookies | ||
+ | utmvCookie = utmvCookie.replace(/ | ||
+ | |||
+ | return (utmvCookie == value) ? true : false; | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | Now, just wrap your call to '' | ||
+ | |||
+ | <code javascript> | ||
+ | <script type=" | ||
+ | var gaJsHost = ((" | ||
+ | document.write(unescape(" | ||
+ | </ | ||
+ | <script type=" | ||
+ | var pageTracker = _gat._getTracker(" | ||
+ | var userDefinedValue = ' | ||
+ | if(!utmvCookieCheck(userDefinedValue)) { | ||
+ | pageTracker._setVar(userDefinedValue); | ||
+ | } | ||
+ | pageTracker._trackPageview(); | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | That's it. Now '' | ||
+ | |||