简体   繁体   中英

Google Analytics eCommerce tracking custom items

I have a question regarding tracking conversions and adding custom items if possible, I currently have installed the eCommerce tracking snippet on a hotel website to track reservations and it is working fine when passing REVENUE (total price), ID (confirmation number) and NAME (room name). However, there other few items I would like to transmit as well such as number of nights and arrival and departure dates so my question is, can I include custom items to the addTransaction object? or rename ones that I don't need like shipping and 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');

I'm using the analytics.js library by the way Thanks for your help

https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-activities Create a product level custom dimension instead Eg:

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).
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM