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
-
Event/Goal Tracking For EKM Powershop
Hi There, I have a client with EKM powershop. I am trying to figure out a way to either setup goal tracking (however I don't know what the final destination page is) or event tracking. I know I can do the ecommerce tag thing, but I am always worried about breaking the tracking code. Any ideas?
Reporting & Analytics | | nezona0 -
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 -
What Parameters and Rules i set to track all types of click?
Hello Expert, If i want to track all types of clicks either link, button, drop down etc for my website then what parameters i add in "Event Tracking parameters" and what will be firing rules. I already have universal analytic and google tag manager. Track Type as even i selected in google tag manager now please tell me 1) what i add in category, Action, label? 2) what should be the rule. I will be really thankful to you if you give cut to cut answer instead of sharing post.
Reporting & Analytics | | bkmitesh0 -
GA Goal Tracking for Proactive Chat
Hi all, Just wondering whether anyone knows how I'd be able to track Proactive Chats as a goal in Google Analytics? So when someone visits our site, and we proactively contact them by initiating a chat (rather than a reactive chat where the visitor initiates it). Thanks!
Reporting & Analytics | | AdrianCordiner0 -
Is it possible to attached separate analytic codes for each campaign?
I am having difficulty in using different GA codes for each individual campaign- this must be possible. Can someone please advice. Thanks
Reporting & Analytics | | ChrisDingley0 -
Image Search Keyword Tracking With Google Analytics
Does anyone know how to track keywords for your images in Google, Yahoo, Bing (/imgres)?
Reporting & Analytics | | Melia0 -
Switching from synchronous to asynchronous code in GA
Morning all, I'm looking to integrate GA with Webmasters tools but to do so I need to have the new asynchronous GA code implemented into my website. Now, I'm happy to just copy and paste the new code into my site footer, but will that any effect on the data that I've already tracked? Is there any reason why this is really not a good idea? Thanks for your help,
Reporting & Analytics | | theshortstack0 -
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