在 iframe 中运行 Google Analytics? [英] Running Google Analytics in iframe?

查看:27
本文介绍了在 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>

我们希望对affiliate.oursite.com 进行Google Analytics 跟踪.目前,当从 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 不喜欢访问有关不同域中页面的信息,并且 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.

有没有人有办法解决这个问题?我们需要将affiliate.oursite.com CNAME 到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天全站免登陆