1

我正在运行多个域,它们都链接到相同的 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>

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

4

0 回答 0