0

我没有通过任何事件,我不知道为什么不。

由于我们要求实施此脚本的经销商在他们的页面上也有他们自己的 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']);
// Recommended 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 天似乎有点多。

4

1 回答 1

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

于 2013-06-20T13:42:17.873 回答