is it possible to send custom variables to Google analytics while using ecommerce extension

别说谁变了你拦得住时间么 提交于 2019-12-08 08:45:18

问题


So basicly i'm trying to get custom variables trough to google analytics panel while using ecommerce extension. My main goal is to give every item a set of custom values.

My "code" looks like this:

ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
    'id': 'id',                     
    'affiliation': 'affiliation',  
});
ga('ecommerce:addItem', {
    'id': 'id',
    'name': 'Loan  - name',
    'sku': '{RIDA:success_loan_id}',
    'loanSumEur': 'Sum',
    'loanSumLit': 'Sum LTL',
    'loanLength': 'length',
    'loanData': 'data'
});
ga('ecommerce:send');
ga('ecommerce:clear');

How should I declare those loanSumEur, loanSumLit, loanlength, loanData variables so Google would pass them trough to the google analytics admin panel. Is it even possible ?

It's quite easy to declare custom variables for site tracking, however I got a little bit stuck trying to do the same thing on transaction items.

BR's


回答1:


Yes, it is possible using custom dimensions & metrics.

ga('ec:addProduct', {               // Provide product details in an productFieldObject.
  'id': 'P12345',                   // Product ID (string).
  'name': 'Powerup',                // Product name (string).
  'category': 'Extras',             // Product category (string).
  'variant': 'red',                 // Product variant (string).
  'price': '10.00',                 // Product price (currency).
  'quantity': 2,                    // Product quantity (number).
  'dimension4': 'strong',           // Product-scoped custom dimension (string).
  'metric2': 5                      // Product-scoped custom metric (integer).
});
ga('ec:setAction', 'purchase', {
  'id': 'T12345',
  'revenue': '20.00'
});

ga('send', 'pageview');     // Send transaction data with initial pageview.

See : Custom Dimensions & Metrics - Product-level scope



来源:https://stackoverflow.com/questions/27821900/is-it-possible-to-send-custom-variables-to-google-analytics-while-using-ecommerc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!