以下は、HTMLページの/ headの直前に追加されたGoogleアナリティクスのコードです。htmlページ内のAjax google analyticsイベントトラッキングが動作しない
後var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_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);
})();
私はイベントを呼び出しています場所です...ときに成功したか失敗した...
$.ajax({
url: "/xxx/xx/",
type: "POST",
data: { name: q, seme: o, profile: x }
datatype: "html",
success: function (f) {
_gaq && _gaq.push(["_trackEvent", "contactform", "success", i, p])
},
error: function (f) {
_gaq && _gaq.push(["_trackEvent", "contactform", "crash", i, p])
}
});
しかし、イベントが記録されていない...私は過去から何かを見るために待っています4日間..私はいくつかのテストを行ったが、それは分析に現れていない...何か間違っている? Googleアナリティクスのメインスニペットに余分な行を追加する必要がありますか?
GAは通常のデータを追跡しますが、これらのイベントは追跡しません。
_gaq && _gaq.push(["_trackEvent", "contactform", "success", i, p])
とちょうど
_gaq.push(["_trackEvent", "contactform", "success", i, p]);
かさえ
if (typeof _gaq != "undefined")
_gaq.push(["_trackEvent", "contactform", "success", i, p]);
データが正しく送信されたときを知るためのもう一つのトリックではありません。
_gaq && ...はjs圧縮によって出力されます。実際にif(_gaq)...私はga_debugでテストし、スレッドを更新します。ありがとうございました。 –
ありがとう、あなたはga_debugについて知らなかった。 chromeプラグインをインストールし、私が4番目のパラメータ(この場合はp)に文字列を送信していることがわかりました。 –
Chrome拡張機能へのリンク:https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna – kalenjordan