如何使用Google Analytics跟踪IFrame中的点击次数? [英] How to Track Clicks in an IFrame with Google Analytics?

查看:137
本文介绍了如何使用Google Analytics跟踪IFrame中的点击次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在自行托管的WordPress网站上跟踪iframe中的出站点击次数。我已经使用Google Analytics(分析)跟踪入站访问者(标题中的GA代码),但我想知道哪些访问者在我的每个页面上点击了iframe中的链接。为了记录,iframe确实来自外部广告客户。



这是我给出的iframe代码(使用样本名称代替真实代码):

 < iframe src =http://www.advertisersite123.com//widget.html?width=510&height=950& product = 2frameborder =0scrolling =nowidth =510height =950>< / iframe> 

这行代码目前被粘贴在single.php上,每个单独的链接都会出现发布在页面底部。



我想知道有多少点击(一般点击都很好,不需要知道他们去哪儿)正在发生在这个iframe中。理想情况下,我的网站上的每个网址都会进行细分,这样我就可以确定哪些网址在iframe中生成点击的成功率更高。

如果可能的话,我希望创建一个漏斗,告诉我哪些访问者(通过源代码)通过点击iframe退出我的网站。

这是否有可能?如果是这样,我会添加哪些代码到页面?

感谢您的任何和所有帮助,非常感谢!

解决方案

你所要求的并不容易。一般来说,如果父页面上没有托管在同一个域中的javascript页面,则该页面可以挂钩到iframed页面上的事件。尝试访问父页面的DOM的iframe页面也是如此。这被称为跨站点脚本(XSS),它违背了相同的域名策略。

至少,最简单的做法是将GA代码放在iframed页面上。但是,这可能不是你可以做的事情(尽管询问供应商不会有什么伤害)。但是一些供应商(通常是社交媒体供应商,如Facebook,Google和其他公司Twitter)将有他们的小部件输出一个iframe W /信息。他们将设置他们的服务器以允许跨域脚本,这将允许您使用iframe的DOM。通常他们提供了一个API以及小部件,使得它更容易挂钩相关的事件(比如共享事件),所以你不必自己编写(很多)。

基本上长话短说,如果没有负责iframe域的负责人参与,没有办法跟踪它。

I'd like to track outbound clicks within an iframe on my self-hosted Wordpress site. I already use Google Analytics to track inbound visitors (GA code in the header), but I'd like to know which/how many of those visitors click on links within the iframe on each of my pages. For the record, the iframe does come from an external advertiser.

This is the iframe code I was given (using sample names in place of real ones):

<iframe src="http://www.advertisersite123.com//widget.html?width=510&height=950&product=2" frameborder="0" scrolling="no" width="510" height="950"></iframe>

This line of code is currently pasted on single.php, making a table of links appear on every single post at the bottom of the page.

I'd like to know how many clicks (just clicks in general is fine, don't need to know where they go) are occurring in this iframe. Ideally broken down by each individual URL on my website so I can determine which URLs are more successful in generating clicks within the iframe.

And if possible, I'd like to create a funnel that tells me which visitors to my website (by source) exit via clicks in the iframe.

Is any of this possible? And if so, what code do I add to the page?

Thank you for any and all assistance, it is appreciated!

解决方案

What you are asking for is not easily done. In general, you cannot have javascript on the parent page that can hook into events on the iframed page if it is not hosted on the same domain. Same thing for the iframe page trying to tap into the parent page's DOM. This is called cross-site scripting (XSS), which goes against the same domain origin policy.

At a minimum, the easiest thing to do would be to put the GA code on the iframed page. But that's probably not something you can do (though it couldn't hurt to ask the vendor).

But some vendors (usually social media vendors such as Facebook, Google and Twitter) will have their widgets that output an iframe w/ info. They will set their server to allow for cross-domain scripting, which would allow you to tap into the iframe's DOM. Usually though they provide an API along with the widget that makes it easier to hook into relevant events (like share events), so that you don't have to do (much) coding yourself.

Basically long story short, there's no way for you to track it without the person in charge of the iframe domain getting involved.

这篇关于如何使用Google Analytics跟踪IFrame中的点击次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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