2012-03-25 9 views
2

Googleアナリティクスで404につながるパスをトラッキングしたいと考えています。Googleアナリティクス - トラック404リファラー

マイGoogleアナリティクスJS:

<script type="text/javascript"> 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-11111111-1']); 
    _gaq.push(['_setDomainName', 'example.com']); 
    _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> 

リファラJS:でも、何を待って4日後の

<script type="text/javascript"> 
try{ 
var pageTracker = _gat._getTracker("UA-11111111-1"); 
pageTracker._trackPageview("/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer); 
} catch(err) {} 
</script> 

はAnalyticsの概要に表示されます。 (自分で404エラーが発生しました) コードに何か問題はありますか?

答えて

7

非同期と非同期のGAコードが混在しているため、予測できない結果につながる可能性があります。

全体後者のスクリプトブロックを置き換えることができ

:に難しいというフォーマットが読みにくいことができますので、あなたは、あなたのページビューデータをオーバーロードイベントトラッキングを使用することを検討したい、としないことがあり

_gaq.push(["_trackPageview", "/404.html?page=" + document.location.pathname +  document.location.search + "&from=" + document.referrer]); 

、分析し、あなたの404エラーのための2つのページビューを送信しているので、何404が今までバウンスとして記録されないことを意味します(ケースになりそうではありません。)

_gaq.push(["_trackEvent", "404", location.pathname + location.search, document.referrer, 0, true]); 

これは、非相互作用をお送りしますイベントではなく、あなたの404の場所を把握できるだけでなくあなたの直帰率には影響しません。また、参照者と404'着陸ページの両方でデータをグループ化することができます。

+0

私のイベントでは、「パス名なし」の「404」しか表示されません。 ** location.pathname **の代わりに** document.location.pathname **に設定する必要がありますか?これは何が原因ですか?ありがとう。 – Tom

関連する問題