2012-04-20 35 views
0

在此之後guide過濾在谷歌Analytics(分析)以pageTracker使用基於cookie被排除在谷歌Analytics(分析)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Excluding traffic by Cookie Content</title> 
<meta name=.robots. content=.noindex. /> 
<!-- Google Analytics Code --> 
<script type="text/javascript">// <![CDATA[ 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); //use real profile ID here 
    _gaq.push(['_trackPageview']); 
    _gaq.push(['_trackPageLoadTime']); 
    (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); 
    })(); 
// ]]></script> 
<!-- Google Analytics Code --> 
</head> 
<body onLoad="javascript:pageTracker._setVar('filter');"> 
<h1>Excluding traffic by Cookie Content</h1> 
<p>This page will set a cookie in your browser that will help Google Analytics filter the traffic that comes from your computer when using this browser.</p> 
<p>Once you have this setup, don't forget to set a filter in Google Analytics.</p> 
<p>You will need to visit this page only once.</p> 
<p>However, if you clear your browser cookies, reinstall the browser or operating system, make sure that you revisit this page, so the cookie will be set again.</p> 
</body> 
</html> 

我得到的錯誤管理業務沒有定義。我一起黑了一個變化,這沒有pageTracker錯誤,但我不知道我是這樣做的權利。

<html> 
<head> 
<script type="text/javascript"> 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);//use real profile ID here 
    _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); 
})(); 

</script> 
<script type="text/javascript"> 
try { 
    var pageTracker = _gat._getTracker("UA-XXXXXXX-X");//use real profile ID here 
    pageTracker._trackPageview(); 
    pageTracker._setVar('founders'); 
} catch(err) {} 
</script> 
</head> 
</html> 

我上面正確的是什麼?

回答

0

@mike是正確的,我是混合技術,我用異步結束,因爲它工作;)

變種_gaq = _gaq || []; _gaq.push(['_ setAccount','UA-XXXXXXXX-X']); _gaq.push(['_ trackPageview']); _gaq.push(['_ setVar','trackme']​​);

(函數(){ VAR GA =使用document.createElement( '腳本'); ga.type = '文本/ JavaScript的'; GA .async = TRUE; ga.src =(的 'https:'= = document.location.protocol?'https:// ssl':'ht tp:// www')+'.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script' )[0]; s.parentNode.i nsertBefore(ga,s); })();

1

看起來您正在將傳統風格分析(pageTracker._setVar...)與異步樣式分析(_gaq.push...)混合使用。

你可以跟蹤對象的副本與_gat._getTrackerByName() - 嘗試在你的身體的onload使用此:

_gat._getTrackerByName()._setVar('filter');