Configure Enhanced Tracking for product views
Posted: Thu Dec 18, 2014 5:46 pm
I'm planning on adding the enhanced e-commerce tracking code, this is the google analytics code :
I confused how to make it track each products and what should be put inside the addImpression parameter (id, name, category, etc) ?
thank you
Code: Select all
<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', '[ENTER MAIN PROPERTY ID]', 'auto');
ga('create', '[ENTER TEST PROPERTY ID]', 'auto',{'name': 'newTracker'}); // New tracker
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]',// 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]',// Product brand - Type: string
'variant': '[Server Variable]', // Variant of the product like color, size etc - Type:string
‘price’: [Server Variable], // Product price - Type: numeric
'list': '[Server Variable]', // Product list - Type: string
'position': [Server Variable] // Product position in a list - Type: numeric
});
});
ga('newTracker.send', 'pageview'); // Send product impressions with initial pageview
ga('send', 'pageview');
</script>
thank you