虽然我可以看到实时,但异步Google分析无法正常工作

时间:2013-06-19 07:34:16

标签: google-analytics

我没有收到任何事件,我不知道为什么不能找到错误我真的很感激。

由于我们要求实施此脚本的转售者在其页面上也有自己的Google分析脚本,因此有两个UA代码,但我不认为这应该是一个问题,但我不确定是否有一些代码是冲突的。

以下是完整的代码:

function CaraConfig() {

    _gaq.push(['_setAccount', 'UA-30022982-26'],      //The GA account id (supplied by E-Tale)
        ['_setDomainName', 'none'],                             // the main page domain name
        ['_setAllowLinker', true],                                   // enables domain linking
        ['_setCampNameKey', 'etale'],                                 //tells us that this has come from us
        ['_setAllowHash', false],                                   //set to false so the cookie can be read
        ['_trackPageview']);
}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39258562-1']);
// Recommanded value by Google doc and has to before the trackPageView
_gaq.push(['_setSiteSpeedSampleRate', 5]);

_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);
})(); 
    var _gaq = _gaq || [];


function CaraGetWidgetDescription(manufacturerWidget) {
    CaraConfig();
    _gaq.push(['_setCustomVar', 1, 'Widget Impression ID E-tale', String(manufacturerWidget)]);

}



function CaraAddToBasket(productName, sku) {

    CaraConfig();
    _gaq.push(['_trackEvent', String(productName), 'AddToBasket', String(sku)]);
}

function CaraBeginTransaction(orderNo, totalPrice) {

    CaraConfig();
    _gaq.push(['_addTrans', String(orderNo), "", CaraPriceFix(String(totalPrice)), "", "0.00", "", "", ""]);
}

function CaraAddTransactionItem(orderNo, sku, productName, productCategory, productPrice, quantity) {

    CaraConfig();
    _gaq.push(['_addItem',
        String(orderNo),
        String(sku),
        String(productName),
        String(productCategory),
        CaraPriceFix(String(productPrice)),
        String(quantity)]);
}

function CaraEndTransaction() {

    CaraConfig();
    _gaq.push(['_trackTrans']);
}

function CaraPriceFix(price) {

    var fixedPrice = price;

    var pLength = price.length;
    var comma = price.indexOf(",") + 1;
    var period = price.indexOf(".") + 1;

    //comma is in the price
    if (comma != 0) {
        //if the comma is not at a 2-decimal point position
        //i.e true for 1,200
        if ((pLength - comma) > 2) {
            fixedPrice = fixedPrice.replace(",", "");
        }
    }
    //period is in the price
    if (period != 0) {
        //if the period is not at a 2-decimal point position
        //i.e true for 1.200
        if ((pLength - period) > 2) {
            fixedPrice = fixedPrice.replace(".", "");
        }
    }
    return fixedPrice;
}

修改

我在4天前更新了我的代码,从那时起我就能看到实时事件,但仍然看不到任何看似奇怪的实际报告。我知道有一个滞后但是4天似乎有点多了。有没有人经历过这个?

感谢。

1 个答案:

答案 0 :(得分:1)

要在同一页面上使用两个帐户,您应该使用多个跟踪器,例如:

_gaq.push(
  ['_setAccount', 'UA-XXXXX-1'],
  ['_trackPageview'],
  ['b._setAccount', 'UA-XXXXX-2'],
  ['b._trackPageview']
);

第二个跟踪器的所有命令都应该用前缀命名。

更多详情:https://developers.google.com/analytics/devguides/collection/gajs/?hl=pl#MultipleCommands