Theo dõi Enhanced Ecommerce là một cải tiến hoàn chỉnh so với Ecommerce truyền thống. Nó cung cấp nhiều phương thức để thu thập và phân tích dữ liệu thương mại điện tử, giúp người sử dụng công cụ này có cái nhìn sâu hơn về tương tác thương mại điện tử của người dùng website.

Mục tiêu của bài viết này là cung cấp một nền tảng chung để bạn hoặc nhà phát triển web của bạn có thể triển khai theo dõi Enhanced Ecommerce trên website của bạn.
theo dõi Enhanced Ecommerce 01

Hướng dẫn theo dõi Enhanced Ecommerce trong Google Analytics (Phần 1)

Enhanced Ecommerce là gì?

Enhanced Ecommerce còn được gọi là thương mại điện tử nâng cao, là một tính năng nâng cao của Google Analytics. Không giống mã theo dõi Ecommerce truyền thống, mã theo dõi Enhanced Ecommerce cần được triển khai cùng với những đoạn script từ server của website.
Trong bài viết dưới đây, Guru sẽ chia sẻ rất nhiều mã theo dõi. Mã theo dõi trên bài viết này là những ví dụ, khá giống với mã theo dõi thực tế trên website của bạn. Bạn không nên áp dụng những mã theo dõi này trên website của bạn. Bạn nên tùy chỉnh để phù hợp với sự hoạt động website, máy chủ của bạn.

Danh sách 11 hoạt động mua sắm quan trọng nhất

  1. Người dùng xem chiến dịch quảng cáo nội bộ (như banner nội bộ trên trang chủ).
  2. Người dùng nhấp vào chiến dịch quảng cáo nội bộ và sau đó chuyển đến trang danh sách sản phẩm (có thể là loại trang sản phẩm hoặc trang kết quả tìm kiếm nội bộ).
  3. Người dùng xem một sản phẩm trong danh sách sản phẩm.
  4. Người dùng nhấp vào một trong các liên kết sản phẩm trong danh sách sản phẩm để xem thêm chi tiết về sản phẩm.
  5. Người dùng sau đó xem trang chi tiết sản phẩm.
  6. Người dùng sau đó quyết định mua sản phẩm. Do đó họ thêm một hoặc nhiều sản phẩm vào giỏ hàng của mình.
  7. Người dùng sau đó có thể quyết định xóa một hoặc nhiều sản phẩm ra khỏi giỏ hàng trước khi bắt đầu quá trình thanh toán.
  8. Người dùng quyết định bắt đầu quá trình thanh toán và hoàn tất các bước khác nhau trong quy trình thanh toán.
  9. Người dùng cung cấp thông tin bổ sung trong quá trình thanh toán (như chọn phương thức thanh toán hoặc vận chuyển).
  10. Người dùng cuối cùng đã hoàn tất quy trình thanh toán bằng cách mua hàng.
  11. Người dùng có thể sau đó quyết định yêu cầu hoàn lại tiền của mình.
Trong thương mại điện tử nâng cao, chúng ta có thể theo dõi tất cả 11 hoạt động mua sắm này (và nhiều hơn nữa) để có được cái nhìn sâu rộng về hành vi mua sắm của người dùng.

1. Đo lường số lượt xem của chiến dịch quảng cáo nội bộ

Quảng cáo nội bộ, còn gọi là internal promotion: là những quảng cáo (như banner ads trên trang chủ) đưa người dùng đến những phần khác của website. Ví dụ: bạn có thể chay quảng cáo biểu ngữ trên trang chủ, quảng bá danh mục sản phẩm cụ thể và khi người dùng nhấp vào biểu ngữ sẽ được chuyển đến trang danh mục sản phẩm. Vì vậy, nếu người dùng xem quảng cáo nội bộ 2 lần thì internal promotion impression là 2. Dưới đây là ví dụ về mã theo dõi đo lường internal ad impression:
<script> (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’, ‘UA-XXXXX-YY’, ‘auto’); ga(‘require’, ‘ec’); ga(‘ec:addPromo’,{ // promoFieldObject stores internal promotion impression data ‘id’: ‘[Server Variable]’, // internal ad ID – Required – Type: string – Example: ‘homeBanner1’ ‘name’: ‘[Server Variable]’, // internal promotion campaign Name – Type: string – Example: ‘Spring sale’ ‘creative’: ‘[Server Variable]’, // internal ad name – Type: String – Example: ‘Spring Sale banner1’ ‘position’: ‘[Server Variable]’ // Position of the internal ad – Type: string – Example: ‘home top banner’ }); ga(‘send’, ‘pageview’); </script>
Mã theo dõi này được đặt trên trang web nơi bạn đang chạy quảng cáo nội bộ và bạn muốn đo lượt hiển thị. Ở đây: ga(‘require’, ‘ec’); là một lệnh Google Analytics được sử dụng để tải plugin enhanced ecommerce. Nếu không có plugin này thì mã theo dõi enhanced ecommerce sẽ không hoạt động. ga(‘ec:addPromo’,promoFieldObject); là lệnh enhanced ecommerce được cải tiến được sử dụng để thu thập và lưu trữ dữ liệu hiển thị của chiến dịch quảng cáo nội bộ. Lệnh này được tạo thành bởi – ec:addPromo đó là lệnh của Google Analytics được sử dụng để đo lường số lần hiển thị quảng cáo nội bộ và gửi dữ liệu hiển thị tới promoFieldObject. – promoFieldObject là một đối tượng JavaScript được sử dụng để lưu dữ liệu hiển thị của các chiến dịch quảng cáo nội bộ:
{
// promoFieldObject stores internal promotion impression data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
}
Sau đây là các thuộc tính khác nhau của promoFieldObject:
  1. id
  2. name
  3. creative
  4. position
[Server Variable] – đây là các biến của server. Bạn cần yêu cầu nhà phát triển của mình viết một script chứa các trường khác nhau của server (server variables) cho mã theo dõi ở trên, với dữ liệu thực tế. Lưu ý: sử dụng thuộc tính ID GA của bạn (thay vì ‘UA-XXXX-YY’) cho mã theo dõi ở trên. Bây giờ mình sẽ giải thích chi tiết các thành phần khác nhau của mã theo dõi được sử dụng để đo lường số lần hiển thị của chiến dịch quảng cáo nội bộ.

Giới thiệu về hit và hit type

Trong ngữ cảnh của Google Analytics, một hit là một tương tác của người dùng với trang web hoặc ứng dụng trên di động. Dữ liệu đó được gửi đến Google Analytics Web Property còn được gọi là hit. Loại dữ liệu được gửi đến Google Analytics Web Property còn được gọi là hit type. Ví dụ như, ‘pageview’, ‘event’, ‘transactions’, ‘item’ v.v. tất cả đều là hit type.

Giới thiệu về tracker

Tracking object (hay còn được gọi là tracker) được sử dụng để gửi dữ liệu truy cập đến Google Analytics Web Property. theo dõi Enhanced Ecommerce 02 Nếu không tạo và sử dụng tracking object đầu tiên thì bạn không thể gửi dữ liệu hit đến Google Analytics Web Property. Lệnh “create” trong Google Analytics được sử dụng để tạo một tracking object và liên kết tracking object với thuộc tính web. Ví dụ như dòng mã sau đây tạo một đối tượng theo dõi mặc định.
ga(create,UAXXXXXYY,auto);
Bạn có thể xem dòng mã này trong đoạn code Google Analytics của mình.

Giới thiệu về Plugin Enhanced Ecommerce

Để thực hiện theo dõi enhanced ecommerce trên website của bạn, thì bạn cần phải sử dụng plugin enhanced ecommerce (còn được gọi tắt là “ec”). Lệnh GA được sử dụng để tải plugin thương mại điện tử nâng cao là:
ga(require,ec);// load enhanced ecommerce library
Lệnh này tương tự như lệnh được sử dụng để tải plugin thương mại điện tử truyền thống trong Google Analytics:
ga(require,ecommerce);// load traditional ecommerce library

Cách sử dụng Plugin Enhanced Ecommerce

Cũng giống như plugin thương mại điện tử truyền thống, plugin thương mại điện tử nâng cao cũng phải được tải, sau tracking object và trước khi bạn sử dụng bất kỳ lệnh theo dõi thương mại điện tử nâng cao nào (ví dụ như: ec: addProduct). Ví dụ như:
<script>
(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,UAXXXXXYY,auto);
ga(require,ec); // load enhanced ecommerce plugin
ga(ec:addPromo,{
// promoFieldObject stores internal promotion impression data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
ga(send,pageview);
</script>
Nếu bạn tải plugin enhanced ecommerce trước tracking object, thì mã theo dõi enhanced ecommerce sẽ không hoạt động. Ví dụ như đoạn mã theo dõi enhanced commerce sau sẽ không đo lường được số lần hiển thị của chiến dịch quảng cáo nội bộ.
<script>
(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(require,ec);
ga(create,UAXXXXXYY,auto);
ga(ec:addPromo,{
// promoFieldObject stores internal promotion impression data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
ga(send,pageview);
</script>

Gửi dữ liệu enhanced ecommerce cùng với hit

Bạn có thể gửi dữ liệu ecommerce / enhanced ecommerce chỉ cùng với một hit (pageview, event v.v.). Do đó, nếu bạn sử dụng lệnh enhanced ecommerce nhưng không gửi bất kỳ hit nào thì dữ liệu ecommerce của bạn sẽ không được gửi đến Google Analytics. Ví dụ như mã theo dõi sau sẽ không gửi dữ liệu quảng cáo nội bộ đến GA (như mã ga(‘send’, ‘pageview’); bị thiếu):
<script>
(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,UAXXXXXYY,auto);
ga(require,ec);
ga(ec:addPromo,{
// promoFieldObject stores internal promotion data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
<< code to send the hit data is missing >>
</script>
Mã theo dõi chính xác là:
<script>
(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(require,ec);
ga(create,UAXXXXXYY,auto);
ga(ec:addPromo,{
// promoFieldObject stores internal promotion data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
ga(send,pageview);
</script>

Sử dụng lệnh enhanced ecommerce trước khi gửi hit

Nếu bạn sử dụng lệnh enhanced ecommerce sau khi hit được gửi thì dữ liệu ecommerce cũng sẽ không được chuyển đến Google Analytics. Ví dụ như mã theo dõi sau sẽ không gửi dữ liệu hiển thị của quảng cáo nội bộ đến Google Analytics:
<script>
(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(require,ec);
ga(create,UAXXXXXYY,auto);
ga(send,pageview);
ga(ec:addPromo,{
// promoFieldObject stores internal promotion impression data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
</script>
Mã theo dõi chính xác là:
<script>
(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(require,ec);
ga(create,UAXXXXXYY,auto);
ga(ec:addPromo,{
// promoFieldObject stores internal promotion impression data
id:[Server Variable], // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
name:[Server Variable], // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
creative:[Server Variable], // internal ad name – Type: String – Example: ‘Spring Sale banner1’
position:[Server Variable]// Position of the internal ad – Type: string – Example: ‘home top banner’
});
ga(send,pageview);
</script>
Mình đề cập chi tiết như vậy hy vọng sẽ hữu ích cho bạn, đặt biệt là đối với những bạn đang thử nghiệm triển khai enhanced ecomemerce của mình. Nếu như bạn không thấy dữ liệu trong báo cáo enhanced ecommerce trong GA của bạn thì hãy đảm bảo rằng bạn sẽ không mắc sai lầm về mã theo dõi enhanced ecommerce mà bạn gắn trên website của mình.

2. Đo lường click trên chiến dịch Quảng cáo nội bộ

Trong quá trình mua hàng, người dùng có thể nhấp vào những chiến dịch quảng cáo nội bộ trên website. Sử dụng JavaScript Event Handler onClick để đo lường những nhấp chuột vào chiến dịch quảng cáo nội bộ (như banner):
// Call this function when promo click occurs.
function onPromoClick() {
  ga(‘ec:addPromo’, {
// promoFieldObject stores internal promotion impression data
‘id’: ‘[Server Variable]’,    // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
‘name’: ‘[Server Variable]’,  // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
‘creative’: ‘[Server Variable]’, // internal ad name – Type: String – Example: ‘Spring Sale banner1’
‘position’: ‘[Server Variable]’ // Position of the internal ad – Type: string – Example: ‘home top banner’
  });
  // Send the promo_click action with an event.
  ga(‘ec:setAction’, ‘promo_click’);
  ga(‘send’, ‘event’, ‘enhanced ecommerce’, ‘Internal Promotion Click’, ‘[INTERNAL PROMOTION NAME]’);
}
Mã theo dõi này được đặt trên trang web chỗ mà bạn đang chạy quảng cáo nội bộ và muốn đo lường những nhấp chuột. Ở đây: ga(‘ec:setAction’, <action-type>,actionFieldObject); – Lệnh enhanced ecommerce được sử dụng để thu thập và lưu trữ dữ liệu liên quan đến những hành động enhanced ecommerce. Lệnh này được tạo thành:
  • ec:setAction – đây là lệnh của Google Analytics được sử dụng để đo lường những dữ liệu hoạt động của thương mại điện tử và sau đó gửi dữ liệu đến actionFieldObject.
  • <action-type> – biểu thị những hành động ecommerce của người dùng. 1. ‘promo_click’: ví dụ như ga(‘ec:setAction’, ‘promo_click’); // đo lường nhấp chuột lên quảng cáo nội bộ 2. ‘detail’: ví dụ như ga(‘ec:setAction’, ‘detail’); // xem chi tiết sản phẩm 3. ‘add’: ví dụ như ga(‘ec:setAction’, ‘add’); // đo lường sản phẩm thêm vào giỏ hàng 4. ‘remove’: ví dụ như ga(‘ec:setAction’, ‘remove’); // đo lường xóa sản phẩm khỏi giỏ hàng 5. ‘checkout‘: ví dụ như ga(‘ec:setAction’,’checkout’, {‘option’: ‘visa’}); // đo thêm thông tin về bước thanh toán 6. ‘purchase’: ví dụ như ga(‘ec:setAction’, ‘purchase’,{…}); // đo lường mua hàng 7. ‘refund’: ví dụ như ga(‘ec:setAction’, ‘promo_click’); // đo lường hoàn tiền lại của một hoặc nhiều sản phẩm.
  • actionFieldObject – nó là một đối tượng JavaScript được sử dụng để lưu trữ dữ liệu hành động ecommerce. Ví dụ đối tượng này có thể là những loại sau:
{
// actionFieldObject stores action data
id:VBT145346,                   // Transaction id – Type: string
affiliation:VB Store,           // Store name – Type: string
revenue:37.39,                  // Total Revenue – Type: numeric
tax:2.85,                       // Tax – Type: numeric
shipping:5.34,                  // Shipping – Type: numeric
coupon:SUMMER2018               // Order/Transaction coupon – Type: string
list:Danh muc Ao Thun,           // Product list – Type: string
step: 1,                           // Number representing a step in the checkout process – Type: numeric
option:paypal,   // Used to provide additional info about a checkout step like payment method used- Type: string
};
Sau đây là các thuộc tính của actionFieldObject:
  1. id
  2. affiliation
  3. revenue
  4. tax
  5. shipping
  6. coupon
  7. list
  8. step
  9. option
‘onPromoClick’ có thể ràng buộc với JavaScript event handler ‘onClick’ như sau:
<a href=/tops/onClick=onPromoClick();><img src=/prod/summersalepromo.jpg></a>
Bạn yêu cầu developer viết một script chứa các trường khác nhau (các biến sever) của mã theo dõi của bạn với những dữ liệu thực tế. Lưu ý: Không gửi dữ liệu hiển thị quảng cáo nội bộ cùng với dữ liệu click vào quảng cáo nội bộ chỉ cùng với một hit. Cần phải gửi 2 loại dữ liệu này tách biệt nhau. Mã theo dõi hoàn chỉnh có thể tương tự như sau:
<script>
  (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’, ‘UA-XXXXX-YY’, ‘auto’);
ga(‘require’, ‘ec’);
// Call this function when promo click occurs.
function onPromoClick() {
  ga(‘ec:addPromo’, {
// promoFieldObject stores internal promotion impression data
‘id’: ‘[Server Variable]’,    // internal ad ID – Required – Type: string – Example: ‘homeBanner1’
‘name’: ‘[Server Variable]’,  // internal promotion campaign Name – Type: string – Example: ‘Spring sale’
‘creative’: ‘[Server Variable]’, // internal ad name – Type: String – Example: ‘Spring Sale banner1’
‘position’: ‘[Server Variable]’ // Position of the internal ad – Type: string – Example: ‘home top banner’
  });
  // Send the promo_click action with an event.
  ga(‘ec:setAction’, ‘promo_click’);
  ga(‘send’, ‘event’, ‘enhanced ecommerce’, ‘Internal Promotion Click’, ‘[INTERNAL PROMOTION NAME]’);
}
ga(‘send’, ‘pageview’);
</script>

3. Đo lường số lượt xem sản phẩm

Trong quá trình mua hàng, người dùng có thể xem sản phẩm trong danh sách sản phẩm (trang danh mục sản phẩm hoặc trang kết quả tìm kiếm). Số lượt xem sản phẩm trong một danh sách sản phẩm được gọi là product impression (số lần hiển thị của sản phẩm) Dưới đây là ví dụ về mã theo dõi để đo lường product impression được gắn trên trang danh sách sản phẩm:
<script>
  (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’, ‘UA-XXXXX-YY’, ‘auto’);
ga(‘require’, ‘ec’);
ga(‘ec:addImpression’,{
// ImpressionFieldObject stores product impression data
‘id’: ‘[Server Variable]’, // Product ID/SKU – Type: string
‘name’: ‘[Server Variable]’, // Product name – Type: string
‘category’: ‘[Server Variable]’, // Name of the Product category.
// Use / as a delimiter to specify up to 5 levels of hierarchy (e.g Men/Shirts/T-Shirts) – Type: string
‘brand’: ‘[Server Variable]’,// Name of Product brand – Type: string
‘variant’: ‘[Server Variable]’, // Variant of the product like: color, size etc – Type:string
‘list’: ‘[Server Variable]’, // Name of the Product list like ‘search results’ – Type: string
‘position’: [Server Variable] // Product position in a list. For example 2 – Type: numeric
});
ga(‘ec:addImpression’,{
// ImpressionFieldObject stores product impression data
‘id’: ‘[Server Variable]’, // Product ID/SKU – Type: string
‘name’: ‘[Server Variable]’, // Product name – Type: string
‘category’: ‘[Server Variable]’, // Name of the Product category.
// Use / as a delimiter to specify up to 5 levels of hierarchy (e.g Men/Shirts/T-Shirts) – Type: string
‘brand’: ‘[Server Variable]’,// Name of Product brand – Type: string
‘variant’: ‘[Server Variable]’, // Variant of the product like: color, size etc – Type:string
‘list’: ‘[Server Variable]’, // Name of the Product list like ‘search results’ – Type: string
‘position’: [Server Variable] // Product position in a list. For example 2 – Type: numeric
});
ga(‘send’, ‘pageview’);
</script>
Ở đây, ga(‘ec:addImpression’,impressionFieldObject); là lệnh enhanced ecommerce được sử dụng để thu thập và lưu trữ dữ liệu hiển thị của sản phẩm. Lệnh này được tạo thành:
  • ec:addImpression – đây là lệnh GA thu thập / đo lường số lần hiển thị sản phẩm và gửi dữ liệu đến impressionFieldObject.
  • impressionFieldObject – đây là một JavaScript Object được sử dụng để lưu trữ product impression.
Lưu ý: impressionFieldObject phải có tên hoặc id. Những trường khác là tùy chọn Sau đây là các thuộc tính của impressionFieldObject:
  1. id
  2. name
  3. category
  4. brand
  5. variant
  6. list
  7. position
Lưu ý: bạn nên yêu cầu developer viết script từ phía máy chủ (như php) để lặp lại tất cả cả các sản phẩm trên một trang và gửi dữ liệu product impression cho từng sản phẩm. Nó sẽ tự động điền vào những trường khác nhau của mã theo dõi. Và sau khi tùy chỉnh lại thì mã theo dõi của bạn sẽ khác với mã theo dõi mẫu ở trên.

4. Đo lường click vào sản phẩm trong danh sách sản phẩm

Trong quá trình mua hàng, người dùng có thể nhấp vào sản phẩm trong danh sách sản phẩm, để xem chi tiết về sản phẩm. Để đo lường phải thêm Javascript event handler ‘onClick’ vào các liên kết của tất cả các sản phẩm được liệt kê trên trang (như trang kết quả tìm kiếm sản phẩm hoặc trang danh mục sản phẩm).
// Called when a link to a product is clicked.
function onProductClick() {
ga(‘ec:addProduct’,{
// productFieldObject stores product click and other details
‘id’: ‘[Server Variable]’, // Product ID/SKU – Type: string
‘name’: ‘[Server Variable]’, // Product name – Type: string
‘category’: ‘[Server Variable]’, // Product category – Type: string
‘brand’: ‘[Server Variable]’, // Product brand – Type: string
‘variant’: ‘[Server Variable]’, // Variant of the product like: color, size etc – Type: string
‘position’: [Server Variable] // Product position in a list – Type: numeric Example: 10
});
ga(‘ec:setAction’, ‘click’, {list: ‘[Server Variable]’});
  // Send click with an event, then send user to product page.
  ga(‘send’, ‘event’, ‘enhanced ecommerce’, ‘Product clicks’, [Product]});
}
Ở đây, ga(‘ec:addProduct’,productFieldObject); là lệnh enhanced ecommerce được sử dụng để thu thập và lưu trữ tất cả dữ liệu sản phẩm. Lệnh này được tạo thành bởi: – ec: addProduct – đây là lệnh Google Analytics thu thập / đo lường tất cả dữ liệu sản phẩm (trừ dữ liệu hiển thị sản phẩm) và sau đó gửi dữ liệu sản phẩm đến productFieldObject. – ProductFieldObject – nó là một JavaScript object được sử dụng để lưu trữ tất cả dữ liệu sản phẩm (trừ dữ liệu hiển thị sản phẩm). Dữ liệu của các loại sản phẩm sau đây được lưu trữ trong JavaScript object này:
  1. Các sản phẩm đơn lẻ được xem trong danh sách sản phẩm
  2. Sản phẩm có trang chi tiết đã được xem
  3. Sản phẩm được thêm vào giỏ hàng
  4. Sản phẩm đã được xóa khỏi giỏ hàng
  5. Sản phẩm ở các bước của quá trình thanh toán
  6. Sản phẩm được mua
  7. Sản phẩm được hoàn lại tiền
Sau đây là các thuộc tính của productFieldObject:
  1. id
  2. name
  3. category
  4. brand
  5. variant
  6. price
  7. quantity
  8. coupon
  9. position
ga(‘ec:setAction’, ‘click’, {list: ‘[LIST NAME]’}); – đây là lênh enhanced ecommerce được sử dụng để đo lường nhấp chuột lên liên kết sản phẩm trong danh sách sản phẩm. Developer cần phải viết một đoạn script máy chủ để gửi dữ liệu click của bất kỳ sản phẩm nào trong danh sách sản phẩm. Script này sẽ tự động điền vào những trường khác nhau của mã theo dõi của bạn Chức năng của ‘onProductClick’ có thể được gắn thông qua Javascript event handler ‘onClick’ giống như dưới đây:
<a href=/tops/figber/onClick=onProductClick();><img src=/prod/figber.jpg></a>
Mã hoàn chỉnh có thể giống như dưới đây:
<script>
  (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’, ‘UA-XXXXX-YY’, ‘auto’);
ga(‘require’, ‘ec’);
// Called when a link to a product is clicked.
function onProductClick() {
ga(‘ec:addProduct’,{
// productFieldObject stores product click and other details
‘id’: ‘[Server Variable]’, // Product ID/SKU – Type: string
‘name’: ‘[Server Variable]’, // Product name – Type: string
‘category’: ‘[Server Variable]’, // Product category – Type: string
‘brand’: ‘[Server Variable]’, // Product brand – Type: string
‘variant’: ‘[Server Variable]’, // Variant of the product like: color, size etc – Type: string
‘position’: [Server Variable] // Product position in a list – Type: numeric Example: 10
});
ga(‘ec:setAction’, ‘click’, {list: ‘[Server Variable]’});
  // Send click with an event, then send user to product page.
ga(‘send’, ‘event’, ‘enhanced ecommerce’, ‘Product clicks’, [Product]});
ga(‘send’, ‘pageview’);
</script>
Phía trên là toàn bộ Phần 1 của bài viết “Hướng dẫn theo dõi Enhanced Ecommerce trong Google Analytics”. Guru hy vọng bài viết này sẽ giúp bạn thu thập được nhiều “bí kíp” bổ ích. Hãy tiếp tục theo dõi và cập nhật kiến thức mới tại bài viết “Hướng dẫn theo dõi Enhanced Ecommerce trong Google Analytics (Phần 2)” của Guru nhé.]]>

ĐỐI TÁC TIN CẬY CỦA HƠN 5000
DOANH NGHIỆP VÀ THƯƠNG HIỆU HÀNG ĐẦU

GURU.EDU.VN TỰ TIN LÀ ĐỐI TÁC
CAO CẤP CỦA GOOGLE ADS, ĐỐI TÁC FACEBOOK ADS

Bạn muốn tự tay set up chiến dịch quảng cáo nhưng không biết bắt đầu từ đâu? Có nên tham gia khóa học quảng cáo Google Ads? Đơn vị nào dạy Google Ads chất lượng? Tất cả câu hỏi trên sẽ được giải đáp tại Học viên Guru - Học viện đào tạo Google Ads uy tín hàng đầu Việt Nam. Tại đây, bạn sẽ được hướng dẫn tận tình bởi các giảng viên có nhiều năm kinh nghiệm trong lĩnh vực, đảm bảo khi hoàn thành khóa học quảng cáo Google Ads bạn có thể tự tin thực hiện chiến dịch quảng cáo một cách tối ưu nhất.

THÔNG TIN LIÊN HỆ

CÔNG TY CỔ PHẦN QUẢNG CÁO CỔNG VIỆT NAM

TRỤ SỞ CHÍNH

Văn phòng HCM: Tầng 8, Tòa nhà Việt - Úc, 402 Nguyễn Thị Minh Khai, Phường 5, Quận 3, TP.HCM.

VĂN PHÒNG HÀ NỘI

Văn phòng HN: Tầng 12A - Tòa nhà Viet Tower - số 1 Thái Hà - Phường Trung Liệt - Quận Đống Đa - TP. Hà Nội.
Mã số thuế: 0313547231

TỔNG ĐÀI HỖ TRỢ ( GỌI MIỄN PHÍ )

THÔNG TIN THANH TOÁN

Chủ tài khoản: Công ty Cổ Phần Quảng cáo Cổng Việt Nam
Số tài khoản: 19129832121014
Ngân hàng: TECHCOMBANK- Chi nhánh HCM