1

我们目前在表单感谢页面上设置了 Google Analytics 电子商务跟踪。我们还使用 Optimizely 在我们的网站上运行 A/B/n 测试。Optimizely 是一个在线拆分测试平台,您还可以配置收入跟踪。

我们希望 Optimizely 收入跟踪启动并运行,但受限于表单可以按代码推送的内容。我希望找到一种解决方案,我们可以将 GA 电子商务代码段中的收入数据提取到同一页面上的 Optimizely 代码段中。

这是 GA 电子商务代码段:

//Ecommerce Tracking Code 
if (pageName == 'thankyou') { 
    //Pull apart and use pieces of the HTML Document.Title
    //where proposed convention is :: Fund - eventName - eventVersion
    //changes based on provided example: 
    var pageIdentity = document.title;

    var parsePageName = pageIdentity.split(" - ");
    var fundName = parsePageName[0];        
    var eventName = parsePageName[1];
    var eventVersion = parsePageName[2];


    var paymentType = "oneTimeCreditCard";
    var donationAmount = "$5.00";
    var constituentID = "13921362";
    var eventID = gup('eventid')||gup('eid');


    //handles ecommerce transaction variables populated for GA
    amount = getPaymentAmount("#ctl00_ctl00_mainContent_bodyContentPlaceHolder_hidDonationAmount"); 

    pageTracker2._addTrans(constituentID, "PaymentNew", amount,"","","","",""); 
    pageTracker2._addItem(constituentID, eventID,fundName+"-"+eventName,paymentType,amount,"1");
    pageTracker2._trackTrans();    
} // if donatethankyou

我们正在尝试将donationAmount 变量(或等效变量)拉入Optimizely 代码段:

window.optimizely = window.optimizely || [];
window.optimizely.push(['trackEvent', 'eventName', {'revenue': valueInCents}]);

目前的设置可以做到这一点吗?我的 JS(显然)非常生锈。

提前致谢!

4

1 回答 1

2

您当前的设置是可能的。

//initiates Optimizely code if it's been loaded, if not queue the function calls in a JavaScript array.
window.optimizely = window.optimizely || [];

    //takes the string for donationAmount variable, replaces the $, converts to string, and multiplies by 100
    var totalPrice = Number(donationAmount.replace(/\$|,/g, '')) * 100;

    //pushes event to optimizely with total.
    window.optimizely.push(['trackEvent', 'thankYouPage', {
        'revenue': totalPrice
}]);

您还需要设定两个目标:

自定义事件(负责优化事件) 在此处输入图像描述

收入(用于查看实验中的收入) 在此处输入图像描述

于 2014-04-02T20:24:47.150 回答