Google analytics使用来自1个网站的iframe内容分析多个域

Google analytics使用来自1个网站的iframe内容分析多个域,iframe,google-analytics,multiple-domains,Iframe,Google Analytics,Multiple Domains,我正在运行多个域,所有域都链接到相同的iFrame内容(一个IBE) 我想跟踪来自我所有3个域的流量,通过iFrame进入这个单独的其他网站。我需要跟踪在线预订何时完成,它来自哪个网站 目前这三个网站上都有以下代码(域名有明显变化 var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXX-X']); _gaq.push(['_setDomainName', 'www.my-example-domain-1.com']); _gaq.

我正在运行多个域,所有域都链接到相同的iFrame内容(一个IBE)

我想跟踪来自我所有3个域的流量,通过iFrame进入这个单独的其他网站。我需要跟踪在线预订何时完成,它来自哪个网站

目前这三个网站上都有以下代码(域名有明显变化

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_setDomainName', 'www.my-example-domain-1.com']);
_gaq.push(['_setAllowLinker', true]);
_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 type="text/javascript">

    function createCookie(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    }

    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    /*
        The cookie should only be created once when the page is first
        entered. After first view by the iframe, subsequent referrers will
        be from acumen.webapplications.com.
        The cookie will persist for a duration of one day.
    */

    if (document.referrer.toLowerCase().indexOf('my-example-domain-2.co.uk') > 0){
        createCookie('analyticsReferrer', 'my-example-domain-2', 1);
    }
    else if(document.referrer.toLowerCase().indexOf('my-example-domain-3.com') > 0){
        createCookie('analyticsReferrer', 'my-example-domain-3', 1);
    }
    else if(document.referrer.toLowerCase().indexOf('my-example-domain-1.com') > 0){
        createCookie('analyticsReferrer', 'my-example-domain-1', 1);
    }

</script>


<script type="text/javascript">
    try { 
    var _gaq = _gaq || [];
        if (readCookie('analyticsReferrer') === "my-example-domain-1"){
            _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
        }
        else if(readCookie('analyticsReferrer') === "my-example-domain-2"){
            _gaq.push(['_setAccount', 'UA-YYYYYYY-Y']);
        }
        else if(readCookie('analyticsReferrer') === "my-example-domain-3"){
            _gaq.push(['_setAccount', 'UA-ZZZZZZZ-Z']);
        }

        _gaq.push(['_setDomainName', 'mybookingenginedomain.com']); 
        _gaq.push(['_setAllowLinker', true]);
        _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); 
        })();       

    } catch(err) {}
</script>

函数createCookie(名称、值、天数){
如果(天){
变量日期=新日期();
date.setTime(date.getTime()+(天*24*60*60*1000));
var expires=“;expires=“+date.togmString();
}
else var expires=“”;
document.cookie=name+“=”+value+expires+“path=/”;
}
函数readCookie(名称){
变量nameEQ=name+“=”;
var ca=document.cookie.split(“;”);
对于(变量i=0;i0){
createCookie('analyticsReferrer','my-example-domain-2',1);
}
else if(document.referer.toLowerCase().indexOf('my-example-domain-3.com')>0){
createCookie('analyticsReferrer','my-example-domain-3',1);
}
else if(document.referer.toLowerCase().indexOf('my-example-domain-1.com')>0){
createCookie('analyticsReferrer','my-example-domain-1',1);
}
试试{
var _gaq=_gaq | |[];
if(readCookie('analyticsReferrer')==“my-example-domain-1”){
_gaq.push([''u setAccount',UA-XXXXXX-X']);
}
else if(readCookie('analyticsReferrer')==“my-example-domain-2”){
_gaq.push([''u setAccount',UA-YYYYYY-Y']);
}
else if(readCookie('analyticsReferrer')==“my-example-domain-3”){
_gaq.push(['''u setAccount','UA-ZZZZZZZZ-Z']);
}
_gaq.push([''u setDomainName',mybookinginegenedomain.com']);
_gaq.push([''设置Allowlinker',true]);
_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);
})();       
}捕获(错误){}

请有人解释一下,为什么预订可能被归因于错误的域,即被归因于域1而不是域2。

对于任何感兴趣的人,我发现跨域脚本是javascript的一个限制,因此解决方案是为每个要链接到的网站提供预订引擎的其他实例。