开发者

Ctrl+Click / Command+Click not working with analytics

开发者 https://www.devze.com 2022-12-31 22:04 出处:网络
I created my own analytics for my site to track outbound click events using jquery. Now the thing with preventDefault() is that it does not allow for the Ctrl+Click or COmmand+click operation in the b

I created my own analytics for my site to track outbound click events using jquery. Now the thing with preventDefault() is that it does not allow for the Ctrl+Click or COmmand+click operation in the browser to open the link in new tab/window. So my solution was to detect e.metaKey || e.ctrlKey and use window.open. This does not work very great with safari unless the user changes browser behavior. I am wondering if anyone here knows wha开发者_开发技巧t other analytics users do - like how does google etc deal with this problem in tracking outbound links? From this link: http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527 - looks like google will also face the same problem.

Thoughts?


The timeout there exists to increase accuracy on Google Analytics Tracking. Without it there's a chance the page unloads before the track goes through.

The good news is, you don't need it if you don't mind about accuracy and are only interested on trendings of outbound link clicking on your website. If you remove that setTimeout call and the return false; from the end of your code it will be ok.

For outbound links a good alternative is to force them to open on new tabs. For that just add a target="_blank" to the links. This way they will always open on new tabs. And you don't need to worry about the tracking not going through, since the page won't unload and, again, can get rid of that setTimeout.

Disclaimer: Personal Opinion Bellow

Web Analytics Tools are not Accurate by design. And that's not bad. They are built to find and measure trends and noise in that trends. So any attempt to increase accuracy in Web Analytics tools won 't pay back. Specially when it comes in the form of ugly Javascript hacks.

Read more about Accuracy X Precision:

http://www.whencanistop.com/2009/11/difference-between-accuracy-and.html

0

精彩评论

暂无评论...
验证码 换一张
取 消