【问题标题】:Pulling revenue data from a Google Analytics e-commerce snippet into another revenue tracking snippet将 Google Analytics(分析)电子商务代码段中的收入数据提取到另一个收入跟踪代码段中
【发布时间】:2014-04-02 18:42:05
【问题描述】:

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

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

这里是GA电子商务sn-p:

//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 sn-p:

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

目前的设置是否可行?我的 JS(显然)非常生锈。

提前致谢!

【问题讨论】:

    标签: javascript google-analytics analytics optimizely


    【解决方案1】:

    您当前的设置是可能的。

    //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
    }]);
    

    您还需要设定两个目标:

    自定义事件(负责优化事件)

    收入(用于查看实验中的收入)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 1970-01-01
      • 1970-01-01
      • 2014-09-17
      相关资源
      最近更新 更多