1
我增加了谷歌Analytics跟蹤事件導航菜單鏈接,使用此代碼:傳遞變量作爲字符串參數gaq.push
(function ($) {
"use strict";
$(function() {
$("body").on('click', '.menu-item a', function() {
var trackingCode = $(this).next(".ga-tracking");
if (trackingCode.length > 0) {
var t1 = trackingCode.data("tracking-1"),
t2 = trackingCode.data("tracking-2"),
t3 = trackingCode.data("tracking-3"),
t4 = trackingCode.data("tracking-4"),
params = "'" + t1 + "','" + t2 + "','" + t3 + "'";
_gaq.push([params]);
}
});
});
}(jQuery));
你可以看到它在這裏工作:http://paulwp.com/blog/ 觸發代碼,點擊頂部黑色欄中的博客鏈接。
這是我的錯誤:
_gaq.push processing "'_trackEvent','Store_Outbound','Link_Click'" for args: "[]":
Called method "'_trackEvent','Store_Outbound','Link_Click'" threw exception.TypeError: Cannot call method 'apply' of undefined
,而它應該給這樣的:
_gaq.push processing "_trackEvent" for args: "[Store_Outbound,Link_Click]":
想這是我建立與變量參數的方式,造成問題的
謝謝你的幫助 – paul 2013-02-08 17:53:19