2
votes

I'd like to know how to implement Enhanced Ecommerce onto my website. From hours of reading up on this topic, I now have a general understanding of how Enhanced Ecommerce works. However, there's literally no websites providing tutorial on how to implement this besides Google's website, which is pretty advanced for someone like me who is not a professional programmer.

Several questions I have regarding Enhanced Ecommerce.

1.) Do I add the enhanced ecommerce code to JUST the "thank you for your order" page of my ecommerce site, or can I add it to all pages of my site?

This is my current Analytics tracking code for all the pages on my website AND ecommerce site.


(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-47765425-1', 'auto');
ga('send', 'pageview');
ga('require', 'ec');

2.) For the product details (SKU, product name, price, etc), how does Analytics retrieve these info? Does it intelligently retrieve these info automatically or do I have to manually create a spreadsheet and input these info, and have Analytics find the info on there? This is what confuses me the most.

3.) Any helpful links to implementing Enhanced Ecommerce that explains question #2?

1
Have you seen the developer guide? developers.google.com/analytics/devguides/collection/… - Matt

1 Answers

2
votes

1) It only needs to be on pages sending the ecommerce events.

2) Best practice is to generate these values when creating the "thank you for your order" page - say from a template. The server-side code has this information and should populate these values (SKU, product name, etc) into the generated html page.

It is possible to store this data in cookies or hidden values on the page and access this data via javascript to build the events - i.e. if whatever software you are using for your shopping cart has this data available, you can simply access this.

3) The closest backend example is with python based on Django but uses the legacy ga.js and only the standard ecommerce tracking: Cartridge.

There is a python object for 'order' that contains the purchase information. Django uses templates to generate the html page - which is the link. The page served contains the javascript events with all the ecommerce requires (SKU, product name, etc).