ECommerce Tracking Code Installation
-
Hi All,
Kindly explain how to implement eCommerce tracking code on the website.I am aware how to enable and generate eCommerce tracking code in Google Analytics but have confusion from website end.Also, where i read the steps, everywhere i read the below code:
<script< span="">type="text/javascript"> var _gaq = _gaq ||[]; _gaq.push(['_setAccount','UA-XXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', '1234', // transaction ID - required 'Acme Clothing', // affiliation or store name '11.99', // total - required '1.29', // tax '5', // shipping 'San Jose', // city 'California', // state or province 'USA' // country ]); // add item might be called for every item in the shopping cart // where your ecommerce engine loops through each item in the cart and // prints out _addItem for each _gaq.push(['_addItem', '1234', // transaction ID - required 'DD44', // SKU/code - required 'T-Shirt', // product name 'Green Medium', // category or variation '11.99', // unit price - required '1' // quantity - required ]); _gaq.push(['_trackTrans']);//submits transaction to the Analytics servers (function(){ var ga = document.createElement('script'); ga.type ='text/javascript'; ga.async =true; ga.src =('https:'== document.location.protocol ?'https://ssl':'http://www')+'.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); ----------------------------------------</script<>
In the above code specific transaction id, SKU/code are mentioned.
What will be the modifications in the above code if i have to track all products present on my eCommerce website??
-
Hi Ruchi!
The reason for this, was that this was an example with three products added to a the cart/order. If you have more products added to the cart, then the _addItem must be repeated for each and every single product/orderline. This code should only reflect the products in just one given transactions, not all the products in your store. You will have to find some way pass this information dynamically when people order products from your store, as this is not hardcoded beforehand - it is to be created dynamically on the fly when a customer loads the final transaction page (like a receipt/thank you-page). There is no special tracking for the individual product pages.
On regular product pages, you only need the standard Google analytics tracking code. In addidtion, you could add a custom _trackEvent for when people add a product to the cart, but this is not mandatory, and does not influence the ecommerce tracking.
Best regards,
Anders
-
In your example, Google will track only three specific products those you have mentioned in your analytic code.
Again, i am repeating my question that how will i track the transaction for "n numbers" of products those are present on my website.Is there any variable that i would have to pass in '_addTrans' and '_addItem' to track.
-
Hi!
I believe this should be a working example:
Hope this helps
Anders
-
Thanks Anders,
It would be great if you can explain it with example or if you have any reference article.
-
Hi Ruchi.
This really depends on what the customer buys. the tracking code you reference above should be placed on the order confirmation/receipt page and should be dynamically filled with transaction ID/SKU's etc based on whatever the customer ends up buying.
- The _addTrans section should be filled with the customers transaction info.
- The _addItem section should be filled with the products bought, (and repeated once for each orderline)
Hope this helps
Best regards,
Anders
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
How to track mobile actions on my website
Hi, i have a website that have, as many others, a mobile version. I want to know if there exist a way to track the mobile user experience, for example, how many times scroll down the page, where touch the screen, and actions that only have sense with mobile visitors. what do you think? Thanks, Juan Ignacio
Reporting & Analytics | | NachoRetta0 -
Tracking Clicks on a Global Header Across Multiple Sites
Hey All, A particular client has multiple websites and we're planning on implementing a global header across 15+ sites. I've been looking for a way to track the clicks on this global header across all sites (that is that they are summed up), what's the best way to go about this if I am using Google Analytics (I know Adobe site catalyst could do this no problem with some advanced tweaking), any ideas? I could do the general click tracking route and tag every link but that will only help me if I do that for each site (that being said, if the global header for all sites pulls from a single HTML, then tagging it would technically count all the clicks from all the sites, the only caveat being that I'd have to pick which Google analytics profile I'd want to track the header with). Thoughts? Thanks!
Reporting & Analytics | | EvansHunt0 -
Does Installing Google Tag Manager Compromise Server Security?
Greetings MOZ community!!! Both my hosting company and developer have told me that in order to install Google Tag Manager it is necessary to disable the rule securing against malicious i-frame attacks in Mod Security and that this would leave the site (we operate on a virtual private server and out hosting company is InMotion Hosting) extremely vulnerable to attack. I can't believe that Google would write code that could allow potential security issues? Is this true? Does anyone know of a way to install GTM while maintaining site security? What functionality will we lose if we choose to stick with the old version of Google Analytics rather than upgrade? Thanks everyone!!!
Reporting & Analytics | | Kingalan1
Alan0 -
Analytics not tracking traffic from Old Domain Redirect
We've recently 301 redirected one of our client's domains to their new website and the strange thing is, we aren't seeing an increase in traffic in analytics. You would expect the traffic to increase roughly by the traffic volume from the old domain. There were a few hundred redirects and we tested a large sample and the redirects have been implemented properly. Is there something that we did incorrectly in our implementation of the domain redirect? Or is there something else that we need to do in Analytics to properly track those redirects?
Reporting & Analytics | | ATMOSMarketing560 -
Event Tracking Not Working
Hey there. Could use some help in figuring on why the event tracking code on this site http://www.baltimoreareahondadealers.com is not working. There is code on all external domain links but none seem to be firing. Inspect all the map links to view code ie. Search New Honda Inventory What am I missing? Thanks so much. -Caryn
Reporting & Analytics | | Caryn0 -
Conversion tracking
Is there a way in GA to setup tracking of the clicking internal URL that 301's to an affiliate ID? Peter
Reporting & Analytics | | PeterM220 -
Tracking Multiple Top Level Domains in GA
Hi, I am setting up Google Analytics for www.example.co.uk and www.example.ie Is this as simple as just adding GA tracking code 'track Multiple top-level domains'? With this method how can I distinguish between each site's incoming traffic? Do filters needed to be created? Thanks in advance 🙂
Reporting & Analytics | | daracreative0 -
Track Google/Bing Shopping as Referrer
Is there a way to track Google & Bing Shopping referrals independent of standard Google/Bing tracking? It would be nice if we could see the difference between Google PPC, Google Organic & Google Shopping. I notice in analytics that we get some traffic from google/ppc, some from google/organic, some from google.com/referral (not sure what this is), and some from googlebase/cse (I know this is Google shopping, but I don't think it's tracking all shopping referral visits as this).
Reporting & Analytics | | JerDoggMckoy0