增强型电子商务,单页应用程序和代码管理器

时间:2016-09-29 14:18:07

标签: javascript google-analytics single-page-application

我们的付款流程刚刚转移到单页应用程序,因此我们需要调整我们向Google Analytics发送增强型电子商务数据的方式。我们在转换之前收到的电子商务数据很好。

我们的Google Analytics代码是通过跟踪代码管理器注入的,我们已经尝试使用虚拟页面网址发送漏斗数据,但尚未成功。

实施此项目的最佳方法是什么?

编辑:我们目前正在尝试通过数据层提供数据并在Tag Manager调试器中看到它,但它似乎没有进入Google Analytics

以下代码 - 电子商务数据在渠道的每个阶段发送。

第一步:

window.dataLayer.push(window.GA_DATA_OBJECT_START); ga('set', 'page', `/profile/?purchaseView=true&product=${this.state.product}`); ga('send', 'pageview');

第二步:

ga('set', 'page', `/profile/?billingConfirmed=true&product=${this.state.product}`); ga('send', 'pageview');

第三步:

window.dataLayer.push(window.GA_DATA_OBJECT_END); ga('set', 'page', `/profile/?purchaseSuccess=true&product=${this.state.product}`); ga('send', 'pageview');

1 个答案:

答案 0 :(得分:0)

如果单页应用程序不使用发送页面视图。

window.ga("ec:addProduct", {
                "id": product.id,                   // Product ID (string).
                "name": product.name, // Product name (string).
                "category": product.category,            // Product category (string).
                "brand": product.company,                // Product brand (string).
                "price": product.price,                 // Product price (currency).
                "quantity": 1
            });
            window.ga("ec:setAction", "remove");
            window.ga("send", "event", "enhanced booking", "leave page", "remove from booking");

另一个例子

window.ga("ec:addProduct", {
                "id": booking._id,                   // Product ID (string).
                "name": booking.name, // Product name (string).
                "category": booking.services[0].category,            // Product category (string).
                "brand": booking.storeTitle,                // Product brand (string).
                "price": booking.price,                 // Product price (currency).
                "quantity": 1
            });
            window.ga("ec:setAction", "purchase", {          // Transaction details are provided in an actionFieldObject.
                "id": booking._id,                        // (Required) Transaction id (string).
                "revenue": booking.companyService.actualPrice,                     // Revenue (currency).
                "coupon": booking.coupon                  // Transaction coupon (string).
            });
            window.ga("send", "event", "Form", "Submit", "Booking Form");

仅将此用于

等展示
window.ga("ec:addImpression", {
    "id": companyId,                   // Product details are provided in an impressionFieldObject.
    "name": companyInfo.name,
    "category": companyInfo.category,
    "list": "Company Info"
});
window.ga("ec:setAction", "detail");
window.ga("send", "pageview");