mercredi 15 octobre 2014

Universal Analytics Values from Style


Vote count:

0




Since my Javascript knowledge is limited, I am having trouble placing the correct Google Universal Analytics code on my Confirmatin page, to track Ecommerce.


The values, such as 'id' should be pulled from the webshop (MyShop.com). Normally, this works by placing it in a span style, such as:



<span style="myshop-value:order-number"></span>


Which pulls the order number value from the database.


When I use below Javascript, the text "myshop-value:order-number" is being placed into Analytics, instead of the ordernumber itself (e.g. 20000_12345)



<script type="text/javascript"> ga('require', 'ecommerce', 'ecommerce.js');

ga('ecommerce:addTransaction', {
'id': 'myshop-value:order-number',
'affiliation': 'auto',
'revenue': 'myshop-value:price-total-formatted',
'shipping': 'myshop-value:price-shipping-formatted',
'tax': '' });
ga('ecommerce:addItem', {
'id': 'span style="myshop-value:order-number',
'sku': 'myshop-value:product-id',
'name': 'myshop-value:description',
'category': 'myshop-value:category',
'price': 'myshop-value:inc-vat-price-formatted',
'quantity': 'myshop-value:quantity'});
ga('ecommerce:send');

</script>


If I use for example:



'id': '<span style="myshop-value:order-number"></span>',


The ordernumber is sent to Analytics, but surrounded by span tags. The other values are not sent.


Does anyone have any suggestions how to pull the "style=" data into Javascript? Help is much appreciated.


Thanks, Richard



asked 1 min ago







Universal Analytics Values from Style

Aucun commentaire:

Enregistrer un commentaire