没有& # 39;标签# 39;在谷歌分析出站链接跟踪
No 'label' in Google Analytics outbound link tracking
我有谷歌分析事件设置跟踪出站链接。我遵循了谷歌网站上的教程。
我遇到的问题是'url'参数(事件标签)没有在谷歌分析中被跟踪。'outbound'和'click'从ga()调用都工作得很好。如果我在ga()调用之前的行中alert() 'url'变量,它将成功地向屏幕发出警告。
为什么类别(出站)和操作(单击)工作得很好?然而,标签(var url)不显示在谷歌分析?
jQuery(document).ready(function() {
initExternalLinkLogging();
});
function initExternalLinkLogging() {
// ':external' is from here and works great: http://stackoverflow.com/questions/1227631/using-jquery-to-check-if-a-link-is-internal-or-external
externalLinks = jQuery("a:external");
jQuery(externalLinks).click(function() {
trackOutboundLink(this);
});
}
function trackOutboundLink(url) {
// This is the triggered on each outbound link click successfully
// 'url' has the correct value, but is not showing up in Google Analytics
try {
ga('send', 'event', 'outbound', 'click', url, {
'hitCallback': function() {
document.location = url;
}
});
} catch (err) {
// Do nothing for now
}
}
我已经解决了这个问题。在这个上下文中,'url'变量是一个对象,尽管屏幕上的警告将其显示为url字符串。只需改变这个函数调用就可以解决这个问题。
//This doesn't work
trackOutboundLink(this);
//This fixes it. See ".href"
trackOutboundLink(this.href);
所以在工作状态下完整的参考代码是:
jQuery(document).ready(function() {
initExternalLinkLogging();
});
function initExternalLinkLogging() {
// ':external' is from here and works great: http://stackoverflow.com/questions/1227631/using-jquery-to-check-if-a-link-is-internal-or-external
externalLinks = jQuery("a:external");
jQuery(externalLinks).click(function() {
trackOutboundLink(this);
});
}
function trackOutboundLink(url) {
// This is the triggered on each outbound link click successfully
// 'url' has the correct value, but is not showing up in Google Analytics
try {
ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
function() {
document.location = url;
}
});
} catch (err) {
}
}
相关文章:
- 谷歌分析跟踪内部链接不正常工作的事件
- 如何在javascript中通过滑动来跟踪链接
- 如何在shopify中使用谷歌分析来跟踪未绑定的链接
- 使用通用分析跟踪出站链接's的hitCallback函数
- 在Qualtrics中单击外部链接时进行跟踪
- 确保通过绑定到链接的GET请求发生跟踪事件
- 使用Javascript链接在Google Universal Analytics中进行跨域跟踪
- 如何根据此方法跟踪Google Analytics中的出站链接,包括.标签和非交互
- 单击超链接的跟踪信息
- 谷歌分析出站链接事件跟踪
- 混合面板 - 跟踪所有链接并获取链接值
- 跟踪外部链接的点击
- Javascript - 获取谷歌跟踪代码管理器点击链接的图像替代文本
- 如何使用javascript跟踪符号链接
- 事件跟踪 - 需要链接在新窗口中打开,而不会被视为弹出窗口
- target=_blank 不适用于 GA 出站链接跟踪
- Omniture链接跟踪Chrome和Safari
- 没有& # 39;标签# 39;在谷歌分析出站链接跟踪
- 出站链接跟踪'undefined'链接
- 实现多链接跟踪