谷歌分析跟踪iframe [英] google analytics tracking on iframe

查看:117
本文介绍了谷歌分析跟踪iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Google Analytics跟踪iframe中的网址?

How to track urls in iframes with Google Analytics?

我所做的是将此代码放入iframe中,就像我在顶部窗口..但是iframe没有在分析中被跟踪?

What I do is that I put this code inside the iframe, like I do on the "top" window.. But the iframe isn't tracked in analytics?

这应该可行,但它不会。:(

This should work, but it doesn't.. :(

<html>
    <head>
        <script type="text/javascript">
            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-35706930-1']);
            _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>
    </head>

    <body></body>
</html>


推荐答案

面值时,没有理由不应该工作。但GA会根据iframe网址进行跟踪,而不是根据父网址进行跟踪,所以如果iframe托管在其他某个域上,则可能会遇到问题,具体取决于GA中的设置。请检查以确保您使用的是正确的帐户#。检查以确保您没有任何配置文件过滤器(例如仅包含xyx.com域名)或设置中的任何其他内容,以排除网域等。

at face value, there's no reason it shouldn't work. But GA will track based on the iframe URL, not the parent URL, so if the iframe is hosted on some other domain, you may have problems, depending on your settings within GA. Check to make sure you are using the right account #. Check to make sure you don't have any profile filters (such as an 'include only xyx.com' domain) or anything else in your settings that exclude domains, etc..

另请注意,如果iframe位于不同的域中,那么就会遇到一般性跟踪问题,就会话和访问(或)度量而言。为了解决此问题,您需要实施其他跨网域跟踪。没有这个不会导致没有数据显示,所以这本身并不是根本问题。

Also note that if the iframe is on a different domain, you're going to run into issues with tracking in general as far as session and visit(or) metrics. In order to get around this, you will need to implement additional cross-domain tracking. Not having this would not cause NO data to show up, so this in and of itself isn't the root issue.

这篇关于谷歌分析跟踪iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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