阻止同一域上的iframe触发Google Analytics中的页面退出

时间:2022-08-23 10:11:27

I am working on a third party website that contains a web application embedded in an iframe on the home page. This iframe is hosted on the same same sub/domain.

我正在开发第三方网站,其中包含嵌入在主页上的iframe中的Web应用程序。此iframe托管在同一个子/域上。

Currently page views are being tracked with _trackPageview. Due to a requirement by marketing both pages use the same Google account Id.

目前正在使用_trackPageview跟踪页面视图。由于营销要求两个网页都使用相同的Google帐户ID。

Since the iFrame was implemented the marketing department has noticed that the bounce rate has dropped to almost nothing. I suspect that this is because Google is interpreting the pageView event on the iframe as the visitor hitting another page on the website.

自iFrame实施以来,营销部门已经注意到跳出率几乎没有下降。我怀疑这是因为当访问者访问网站上的另一个页面时,Google正在解释iframe上的pageView事件。

Just for additional information, the domain of the _gaq object is being set to "none" for both the container page and iframe.

仅为了解更多信息,容器页面和iframe的_gaq对象的域都设置为“none”。

Does Google provide a mechanism by which you can trigger PageView in such a way that it isn't interpreted as subsequent pageview in this scenario? (I know that trackEvent has a noninteraction property to deal with this?)

Google是否提供了一种机制,您可以通过这种机制触发PageView,使其在此方案中不被解释为后续网页浏览? (我知道trackEvent有一个非交互属性来处理这个?)

Am I better off just disabling the PageView for the default iframe page?

我最好只是禁用默认iframe页面的PageView吗?

2 个解决方案

#1


Does Google provide a mechanism - apparently yes, but probably not for your use case.

Google是否提供了一种机制 - 显然是,但可能不适合您的用例。

The field documentation for Universal Analytics describes the non-interaction field thusly:

Universal Analytics的字段文档因此描述了非交互字段:

Specifies that a hit be considered non-interactive.

指定将匹配视为非交互式。

So in UA this does no seem limited to events but to apply to all hits (which would include pageviews). I want to point out that I have no tested it and that it seems counterintutive, so it might simply be that the documentation is incomplete/wrong here.

所以在UA中,这似乎不仅限于事件,而是适用于所有命中(包括浏览量)。我想要指出的是,我没有对它进行测试,而且它似乎具有违宪性,因此可能只是文档在这里是不完整/错误的。

However as you are using "classical" Analytics this does not apply to you. Since upgrading the code is a good idea in any case you might want to push for an update to Universal Analytics (this piqued my curiosity so I will test this over the next few days and update this answer with the results - maybe you want to wait until then, or simply test it yourself).

但是,当您使用“经典”分析时,这不适用于您。由于升级代码是一个好主意,无论如何你可能想要推动对Universal Analytics的更新(这引起了我的好奇心,所以我将在接下来的几天内对此进行测试并用结果更新这个答案 - 也许你想要等待到那时,或者只是自己测试一下)。

#2


It's possible, but not 100% clear to me that disabling the PageView event on the iframe will prevent your users from registering a page exit (the pageview may get recorded regardless). You can try removing that event and see if it works.

这是可能的,但不是100%清楚,禁用iframe上的PageView事件将阻止您的用户注册页面退出(无论如何都可以记录网页浏览)。您可以尝试删除该事件,看看它是否有效。

But a better way may be to implement a custom filter on a new View excluding traffic to that specific class of iframes. Make sure you keep your old View (or create a new one with further filters) to make sure you're capturing those iframe views, if you think that's necessary.

但更好的方法可能是在新视图上实施自定义过滤器,排除流向该特定iframe类的流量。如果您认为有必要,请确保保留旧视图(或使用更多过滤器创建新视图)以确保捕获这些iframe视图。

#1


Does Google provide a mechanism - apparently yes, but probably not for your use case.

Google是否提供了一种机制 - 显然是,但可能不适合您的用例。

The field documentation for Universal Analytics describes the non-interaction field thusly:

Universal Analytics的字段文档因此描述了非交互字段:

Specifies that a hit be considered non-interactive.

指定将匹配视为非交互式。

So in UA this does no seem limited to events but to apply to all hits (which would include pageviews). I want to point out that I have no tested it and that it seems counterintutive, so it might simply be that the documentation is incomplete/wrong here.

所以在UA中,这似乎不仅限于事件,而是适用于所有命中(包括浏览量)。我想要指出的是,我没有对它进行测试,而且它似乎具有违宪性,因此可能只是文档在这里是不完整/错误的。

However as you are using "classical" Analytics this does not apply to you. Since upgrading the code is a good idea in any case you might want to push for an update to Universal Analytics (this piqued my curiosity so I will test this over the next few days and update this answer with the results - maybe you want to wait until then, or simply test it yourself).

但是,当您使用“经典”分析时,这不适用于您。由于升级代码是一个好主意,无论如何你可能想要推动对Universal Analytics的更新(这引起了我的好奇心,所以我将在接下来的几天内对此进行测试并用结果更新这个答案 - 也许你想要等待到那时,或者只是自己测试一下)。

#2


It's possible, but not 100% clear to me that disabling the PageView event on the iframe will prevent your users from registering a page exit (the pageview may get recorded regardless). You can try removing that event and see if it works.

这是可能的,但不是100%清楚,禁用iframe上的PageView事件将阻止您的用户注册页面退出(无论如何都可以记录网页浏览)。您可以尝试删除该事件,看看它是否有效。

But a better way may be to implement a custom filter on a new View excluding traffic to that specific class of iframes. Make sure you keep your old View (or create a new one with further filters) to make sure you're capturing those iframe views, if you think that's necessary.

但更好的方法可能是在新视图上实施自定义过滤器,排除流向该特定iframe类的流量。如果您认为有必要,请确保保留旧视图(或使用更多过滤器创建新视图)以确保捕获这些iframe视图。