在Google Analytics的新窗口中打开链接时,外部链接跟踪中的问题? [英] Bug in external link tracking when opening the link in a new window in Google Analytics?

查看:151
本文介绍了在Google Analytics的新窗口中打开链接时,外部链接跟踪中的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很抱歉,如果在stackexchange站点上交叉发布的礼节被认为是不礼貌的,但这对于网站管理员站点和这里都是适合的,因为这对网站管理员来说是一个常见问题,但可以通过编码人员解决。在任何情况下,这里都是...



好的,所以这看起来像一个非常简单的问题,但我还没有找到一个解决方案来完成以下任务: p>


  • 在新窗口中打开链接
  • 在使用异步代码时跟踪GA中的事件
  • li>
  • 不触发弹出式窗口拦截器(使用target =_ blank而不是window.open)



我看到的大部分代码(包括Google的代码)都没有考虑在新窗口中打开的情况 - 它们只是使用window location.href。



甚至GAAddons(http://gaaddons.com/),商业用途收费,似乎没有妥善管理在新窗口打开。



也许,我我错过了一些简单的东西 - 如果愿意的话,我会感到宽慰的,并且会非常感谢那些向我指出的人!



如果没有人能提供一个例子,我我会发布一些我创建的测试用例来说明问题。



谢谢。

我已经测试了GAAddons代码,并且已经发现它可以工作。我猜测在Windows上使用Chrome 7的客户之前报告的问题更可能是配置问题,而不是与GAAddons库本身相关的问题。 解决方案

我发现满足所有我提到的要求的方法是在这里找到的:
http://cutfromthenorth.com/add-external-link-tracking-with-jquery-and-google-analytics/



其实很简单,这让我认为还有其他一些原因,为什么其他代码在以前的测试中不起作用。

但是,我可以确认在此Google页面的评论中提及的方法 - http://www.google.com/support/googleanalytics/bin/answer.py?hl=zh_CN&answer=55 527 - 不符合上述要求(新窗口在Chrome和IE上触发弹出式警告)。



Google代码可用于跟踪未打开的外部链接



以下是代码片段:

  $( '(a)[target = _blank]')。click(function(){
try {
_gaq.push(''trackEvent','External Links','Click',$(this).attr ( 'href' 属性)]);
} catch(err){}
return true;
});

我在以下浏览器上测试过:
PC:
IE 6 - 9
Firefox 3.6,4.0
Chrome 9,10
Safari 5
Opera 11



Mac:
Safari 5
Chrome 10
Firefox 3.6,4.0

还在iPhone 4和Gingerbread上的原生Android浏览器上进行了测试


First off, I apologize if it's considered poor etiquette to cross-post on stackexchange sites, but this seemed appropriate for both the webmasters site and here, as it's a common issue for webmaster, but may be able to be solved by coders. In any case, here goes...

OK, so this seems like a really simple problem, but I have yet to find a solution that accomplishes the following:

  • Opens the link in a new window
  • Tracks the event in GA when using the asynchronous code
  • Doesn't trigger pop-up blockers (uses target="_blank" instead of window.open)

Most of the code I've seen, including Google's, doesn't take into account the case of opening in a new window - they just use window location.href.

Even GAAddons (http://gaaddons.com/), which charges for commercial use, seems to not manage opening in new windows properly.

Perhaps, I'm missing something simple - I'd be relieved if so and would thank profusely whoever points it out to me!

If no one is able to provide an example, I'll post some of the test cases I've created to illustrate the problem.

Thanks.

[EDIT] I've since tested the GAAddons code more throughly and have found it to work. I'm guessing the problem that was being reported earlier by a client using Chrome 7 on Windows was more likely a configuration issue than something related to the GAAddons library itself.

解决方案

The method I've found to satisfy all the requirements I've mentioned is the one found here: http://cutfromthenorth.com/add-external-link-tracking-with-jquery-and-google-analytics/

It's actually quite simple, leading me to think that there was some other reason why other code wasn't working in earlier tests.

However, I can confirm that the method that's mentioned in the comments on this Google page - http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527 - does not meet the above requirements (new windows trigger popup warning on Chrome and IE).

The Google code does work for tracking external links not opened in a new window.

here's the snippet:

$('a[target=_blank]').click(function(){
try{
    _gaq.push(['_trackEvent', 'External Links', 'Click', $(this).attr('href')]);
} catch(err) {}
return true;
});

I've tested on the following browsers: PC: IE 6 - 9 Firefox 3.6, 4.0 Chrome 9, 10 Safari 5 Opera 11

Mac: Safari 5 Chrome 10 Firefox 3.6, 4.0

Also tested on iPhone 4 and the native Android browser on Gingerbread

这篇关于在Google Analytics的新窗口中打开链接时,外部链接跟踪中的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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