Google Analytics(分析)出站链接事件跟踪 [英] Google Analytics Outbound Link Event Tracking

查看:155
本文介绍了Google Analytics(分析)出站链接事件跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置事件跟踪,以便我可以跟踪某人何时访问我的关于页面,并单击指向我的LinkedIn个人资料的链接。以下是我要跟踪的链接。正如你所看到的,我试图添加一些代码来跟踪工作...我经历了一些不同的技术,但没有任何工作到目前为止。

I'm trying to set up event tracking so that I can track when someone goes to my 'about' page and clicks on a link to my LinkedIn profile. Below is the link that I want tracked. As you can see, i tried to add some code to get tracking working...i went through a few different techniques, but nothing works so far.

这是什么我现在有:

<a ga('send', 'event', 'outbound', 'click', 'linkedin'); href="http://www.linkedin.com/profile/view?id=110370894&amp;trk=nav_responsive_tab_profile_pic" target="_blank">LinkedIn Page</a>

我将继续阅读和插拔,但任何帮助都不胜感激。

I'm going to keep reading and plugging away, but any help is appreciated.

我有 analytics.js 到位。我还在标题部分中实施了代码,以便延迟,以便跟踪将有时间加载,按照此支持文章的建议:

https://support.google.com/analytics/answer/1136920?hl=en

I have analytics.js in place. I also implemented code in the header section to give a delay so that the tracking will have time to load, as recommended by this support post:
https://support.google.com/analytics/answer/1136920?hl=en

另外,想知道这是如何工作的。一旦我得到正确的代码,它会自动显示在我的分析中?在事件下?或者还有什么我要做的吗?

Also, wondering how this works. Once I get the code right, it will automatically show up in my analytics? under events? or is there something else I have to do?

如果这个在别的地方回答了,提前提前,我读了一堆以前的帖子,但我觉得这些人总是有些

Sorry ahead of time if this is answered somewhere else, I read a bunch of previous posts but I feel like theres always some bit of info missing that's just keeping me from getting this right.

推荐答案

问题是浏览器重定向到新的URL之前事件已被正确记录。

The problem is that the browser redirects to the new URL before the event has been properly recorded.

有三种常用方法:


  1. 不好:在重定向之前插入一小段延迟。这是一个不可靠的方法,因为所需的延迟取决于网络的性能。在一个缓慢的网络中,事件可能不会被记录,因为浏览器会很快切换到新的URL。

  1. Bad: Insert a small delay before redirecting. This is an unreliable method because the delay required depends on the performance of the network. In a slow network, the event may not be recorded because the browser will switch to the new URL too soon.

更好的 target =_ blank添加到< a> 元素中。这将打开一个新窗口中的链接,并允许记录事件,因为旧窗口将保持打开状态。

Better: Add target="_blank" to your <a> element. This will open the link in a new window, and will allow the event to be logged because the old window will stay open.

最佳 ga()方法允许在事件成功记录后立即运行回调函数。

Best: The ga() method allows a callback function to be run immediately after the event has been successfully recorded.

<script>
/**
* Function that tracks a click on an outbound link in Google Analytics.
* This function takes a valid URL string as an argument, and uses that
* URL string as the event label.
*/
var trackOutboundLink = function(url) {
   ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
     function () {
     document.location = url;
     }
   });
}
</script>

用法:

<a href="http://www.example.com"
   onclick="trackOutboundLink('http://www.example.com'); return false;">
Check out example.com
</a>

上面的代码是从此页面

这篇关于Google Analytics(分析)出站链接事件跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆