谷歌分析-自定义iFrame跟踪

谷歌分析-自定义iFrame跟踪,iframe,google-analytics,Iframe,Google Analytics,我做了一个小的井字游戏,它在任何时候都能玩得很好。 实际的tic-tac-toe游戏从(/tic)加载并嵌入到iframe中 因此,如果其他人愿意,他们可以很容易地在自己的网站上嵌入游戏 我正在iframe内部进行一些事件跟踪。 现在我已经设置好了,所以它会在两个主页上都触发一个页面视图 以及iframe中的实际游戏代码 我想知道,如果不是的话,我是否只能为iframe启动页面视图 嵌入到另一个站点上 因此,在root(/)下跟踪的所有内容都是我的站点上的流量,以及通过嵌入另一个站点而生成的i

我做了一个小的井字游戏,它在任何时候都能玩得很好。 实际的tic-tac-toe游戏从(/tic)加载并嵌入到iframe中

因此,如果其他人愿意,他们可以很容易地在自己的网站上嵌入游戏

我正在iframe内部进行一些事件跟踪。 现在我已经设置好了,所以它会在两个主页上都触发一个页面视图 以及iframe中的实际游戏代码

我想知道,如果不是的话,我是否只能为iframe启动页面视图 嵌入到另一个站点上

因此,在root(/)下跟踪的所有内容都是我的站点上的流量,以及通过嵌入另一个站点而生成的i frame(/tic)流量中跟踪的所有内容

现在,我在iframe中的分析代码如下所示:

 <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxxxxx-x']);
    _gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

var _gaq=_gaq | |[];
_gaq.push(['''u setAccount','UA-xxxxxxxxx-x']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();

提前非常感谢。

由于您位于单独域上的iFrame中,因此无法访问父窗口以获取位置。查看此演示和/或谷歌一下:

您可以在iFrame页面上使用querystring传递域,您需要修改include代码,如下所示:


文件。写(“”);

然后你会适当地过滤掉你的谷歌分析。

因为你在一个独立域的iFrame中,你不能访问父窗口来获取位置。查看此演示和/或谷歌一下:

您可以在iFrame页面上使用querystring传递域,您需要修改include代码,如下所示:


文件。写(“”);

然后你会适当地过滤掉你的谷歌分析。

你可以使用谷歌分析活动来跟踪流量。您将需要分发已经具有活动参数的嵌入代码,作为嵌入iframes src的一部分

希望有帮助


有兴趣听取别人的意见

您可以使用谷歌分析活动来跟踪流量。您将需要分发已经具有活动参数的嵌入代码,作为嵌入iframes src的一部分

希望有帮助

有兴趣听取别人的意见

_gaq.push(['tictactoe._setAccount', 'UA-xxxxxxxxx-x']);
// Line below causes security issues, thus won't work
_gaq.push(['_setCustomVar', 1, 'Domain', window.parent.location.host, 3]);
_gaq.push(['tictactoe._trackPageview']);
<script type="text/javascript">
document.write('<iframe src="//tic.cwoebker.com/?url=' + window.location + '"></iframe>');
</script>