在iframe中运行Google Analytics(分析)? [英] Running Google Analytics in iframe?

查看:155
本文介绍了在iframe中运行Google Analytics(分析)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们公司运营一个网站(oursite.com),与我们的流量合作伙伴联系。在某些情况下,我们会将我们的关联公司设置为拥有自己的子域名(affiliate.oursite.com),并使用iframe在其网站(affiliate.com)上显示来自我们网站的所选内容。

Our company runs a web site (oursite.com) with affiliate partners who send us traffic. In some cases, we set up our affiliates with their own subdomain (affiliate.oursite.com), and they display selected content from our site on their site (affiliate.com) using an iframe.

他们网站上的网页示例:

Example of a page on their site:

<html>
<head></head>
<body>
<iframe src="affiliate.example.com/example_page.html">
...content...
[google analytics code for affiliate.oursite.com]
</iframe>
[google analytics code for affiliate.com]
</body>
</html>

我们希望Google Analytics(分析)追踪affiliate.oursite.com。目前,当从iframe加载网页时,Google似乎没有从关联企业收到任何数据。

We would like to have Google Analytics tracking for affiliate.oursite.com. At present, it does not seem that Google is receiving any data from the affiliate when the page is loaded from the iframe.

现在,有一些安全隐患,因为Javascript doesn不喜欢访问其他域中的某个网页的信息,IE不喜欢为其他网域设置Cookie。

Now, there are security implications in that Javascript doesn't like accessing information about a page in a different domain, and IE doesn't like setting cookies for a different domain.

有没有人能解决这个问题?我们需要将cNAME的affiliate.oursite.com改为cname.oursite.com,还是有更清洁的解决方案?

Does anyone have a solution to this? Will we need to CNAME the affiliate.oursite.com to cname.oursite.com, or is there a cleaner solution?

推荐答案


  1. 您必须将Google Analytics(分析)跟踪代码附加到 example_page.html 的末尾。 < iframe> - < / iframe> 标签之间的内容仅对不支持

  1. You have to append the Google Analytics tracking code to the end of example_page.html. The content between the <iframe> - </iframe> tag only displays for browsers, which do not support that specific tag.

如果您需要合并子域的结果,请在Google帮助网站上找到一篇很好的文章:如何在一个配置文件中跟踪我的网站的所有子域?

Should you need to merge the results from the subdomains, there's an excellent article on Google's help site: How do I track all of the subdomains for my site in one profile?

这篇关于在iframe中运行Google Analytics(分析)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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