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
-
Google Analytics Stopped Tracking Visits - NEED HELP!
Hi Moz Community, I have about 10 sites, static HTML sites and WordPress sites, which ALL stopped tracking Google Analytics on August 2nd. They go to a flat-line! Dead! No data! Has anyone else experienced this either currently or before? I have confirmed all code is correct as it's been tracking these sites for years. One site gets 5,000+ visits a month and they are sitting at only 1,500 now and will be a fun conversation to have with the client. If all code is correct, what should I do? How do I overcome this without having to re-create another account/tracking ID? Never dealt with something like this before and there is not much on the web or in other forums. Would appreciate any help or advice or tips! - Patrick
Reporting & Analytics | | WhiteboardCreations0 -
I want to track product click so how to create project object or how to pass project object ?
Hey, I am reading this post - https://developers.google.com/tag-manager/enhanced-ecommerce#product-clicksIn this there is function like given below - function(productObj) { dataLayer.push({ 'event': 'productClick', 'ecommerce': {.....................................................................................................................Now my developer asking how to create object? or how to pass product object? Like on page we have more than 50 products listed, so if any one clicks on any product from list then how will we know which product has been clicked?Hope you understand what i want to say? Regards,Mitesh
Reporting & Analytics | | bkmitesh0 -
Does Google Analytics track conversions in real time?
Looking at the section: Conversions > Goals > Overview - does Google Analytics provide real time / same day metrics for this conversion data or does it take 24 hrs?
Reporting & Analytics | | Rich_Coffman0 -
Universal Analytics Ecommerce Tracking in Magento
We have a problem similar to this: http://stackoverflow.com/questions/22229312/universal-analytics-could-not-track-transaction-in-magento On a client's website. I need an absolute knock-out EXPERT at solving this to give us a quote on doing something like this. It's very urgent but it is paid. Basically the site used the old tracking code, worked, then client said they wanted new data so we upgraded to Universal. Now everything works but Ecommerce tracking. Desperately need help! Thanks all!
Reporting & Analytics | | MattAntonino0 -
My GA code is on my site but Google Analytics isn't being pulled into SEOMoz...why?
The CEO wants me to present an SEO plan next week for three of our sites; however, I got this message when I went to campaign overview tab: "It appears there's a problem with our connection to your Google Analytics account. Please go to your Settings page to update your connection." I double-checked the GA code and it's the same on both our site and in SEOMoz...what gives? I clicked on Choose Your GA Profile->Set GA Account and Profile then got this warning: "Are you sure you want to change your Google Analytics connection? Changing your connection will reset our cache of your historical GA traffic data." I need this data pronto so I can set strategy for three sites; any help would be greatly appreciated! Darrell
Reporting & Analytics | | AdviceElle0 -
Subdomain tracking codes on subdomain and not root
Afternoon all. I’m pretty sure this is going to be fine but I thought I would seek some confirmation before I action anything. We have a blog subdomain on our site, I have just noticed that the entire blog (built in Wordpress) has no analytics tracking code on it. As this is built in Wordpress I have just logged in on an admin account I think people forgot I had and added the code to the header section as it is a two second job. My question is this – On the main account, subdomain tracking has not been turned on, so the root domain has not got the additional _gaq.push(['_setDomainName', 'rootdomain.co.uk']); line of code in it. I have included this on the blog.rootdomain.co.uk code as is necessary to enable tracking. Will this work or cause tracking issues? I think it should be ok. I don’t want to have to update the root domain code if I can avoid it as that will need to go through the development team and may take weeks as they are swamped and under resourced. Thanks, Rich.
Reporting & Analytics | | Sarbs0 -
Ecommerce tracking problem with multiple domains on 1 web property
We recently launched 13 product marketing sites based on a Wordpress Multisite setup. To track all 13 sites we decided to use one web property, so we can use the same tracking code for all domains. To track the sites seperately, we set up a profile for each product site with a hostname filter. This works well for most stats, but eCommerce tracking is where the problem starts. Per profile we obviously want to track the products purchases on that website only. What happens now is that all purchases from all product sites are tracked on all profiles. How can we change this? Should I alter the eCommerce tracking code or can I fix this with an additional filter per profile? Thanks for your help Mozzers! Regards, Pieter van Diggele
Reporting & Analytics | | RBO
Online Marketing Executive
Elsevier Opleidingen0 -
Cover my tracks / two websites on the same Analytics
Hi, I've got 2 websites and I like one of them to make some links to the other one. These two sites are on the same Google Analytics account. They have been set up 3 month ago and they have some articles on them. I've heard that Google can see that those websites are related in my Analytics and use this information to give less power to the link I could make between them. What do think about it and what do you recommend me ? Shoud I closed the Analytics account ? Or down one of the website and rebuilt it whith a different domain / host / analytics ? The thing is if I delete one of the website i'll be force to republish the articles, because there are links on it, and they're part of a deal I've already made. Thank you
Reporting & Analytics | | Spleen0