Google Analytics电子商务跟踪自定义项目

时间:2015-10-20 15:36:40

标签: google-analytics e-commerce analytics event-tracking

我有一个关于跟踪转化和添加自定义项目的问题,如果可能的话,我目前已经在酒店网站上安装了电子商务跟踪代码段来跟踪预订,并且在通过收入(总价),ID(确认号码)时工作正常和NAME(房间名称)。但是,还有其他一些我想传输的项目,例如夜晚和到达和离开日期,所以我的问题是,我可以在addTransaction对象中包含自定义项吗?或者重命名我不需要的货物和sku?

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'XXX-XXX-XXX', 'auto');
ga('send', 'pageview');

ga('require', 'ecommerce', 'ecommerce.js');

// General Booking transaction
ga('ecommerce:addTransaction',{  
  'id' : confirmationNumber, // Confirmation Nimber
  'revenue' : totalBooking,  //Booking total plus taxes
  'affiliation' : hotelName, //Hotel name         
  'currency' : 'USD' 
});

// OPTIONAL: detailed room info
ga('ecommerce:addItem', {
  'id': roomID,  // Room ID.
  'name': roomName,    // Room Name
  'price': nightlyRate,    // Nightly rate (maybe)
  'quantity': totalRooms    // Number of rooms.
});

//Send transaction data
ga('ecommerce:send');

我正在使用analytics.js库感谢您的帮助

1 个答案:

答案 0 :(得分:1)

https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-activities创建产品级自定义维度,而不是E.g:

ga('ec:addProduct', {               // Provide product details in a productFieldObject.
'id': 'P12345',                   // Product ID (string).
'name': 'Android Warhol T-Shirt', // Product name (string).
'category': 'Apparel',            // Product category (string).
'brand': 'Google',                // Product brand (string).
'variant': 'Black',               // Product variant (string).
'position': 1,                    // Product position (number).
'dimension1': '4'            // Custom dimension Number of Nights (string).
'dimension2': 'October'       // Custom dimension Arrival Date (string).
});