In Part 2 of this series, Google Analytics Demystified: Part 2 – “Vanilla” Google Analytics I talked about what I call “Vanilla” Google Analytics and provided some helpful insight on how to install it, how to check the status of it, and offered some tips for troubleshooting when it seems Google does not recognize your tracking code.
In Part 3 of this series here, I reveal the secrets to successfully using E-Commerce Tracking in Google Analytics. I’ll briefly go over installation, and then “activation” of Google E-Commerce tracking for Zen Cart. There are two steps required to get e-commerce tracking working, and both need to be completed or you will get “0’s” returned in your statistics.
Keep in mind that to utilize e-commerce tracking, you must first have Google Analytics installed for your website.
E-Commerce Tracking
Google Analytics E-Commerce Tracking is used to track product sales, sales revenues, transaction data, etc… When you install E-Commerce tracking, you’ll get reporting figures for things like “dollar amount of total sales for the period”, “product sales revenues for the period”, “top selling products”, and more.
The code you use to install Google E-Commerce Tracking looks something like this and MUST be placed BELOW the “Basic” Analytic Tracking code (shown above) on the sales RECEIPT page. This is the page a user arrives at after completing a successful sale at your store.
Sample of Google E-Commerce Tracking Code:
Zen Cart users that are utilizing the Simple Google Analytics Contribution do not have to worry about adding any code for e-commerce tracking. It is automatically added for you when you install the contribution. However, you still need to make sure you enable e-commerce tracking from within your Google Analytics Account as indicated below.
Just because you have installed the Google E-Commerce Tracking script on your sales receipt page, doesn’t mean you are ready to track sales data on your website. You must do one more thing in order to let Google know you want to track sales data.
You must tell Google that your site is an “E-Commerce Website” by enabling e-commerce tracking (or you will get “0’s” across the board in your e-commerce statistic reports.)
To do this, you login to your Google Analytics account and go to your Analytics tab then click on the “Edit” link to the right of the website profile you wish to activate e-commerce tracking for.
On the next page you come to (profile settings), click the “Edit” link to the right of the first section heading that says “Main Website Profile Information”. This will bring you to the final screen, and the screen at which you actually “activate” e-commerce tracking for your store.
At this final screen, simply select the “Yes” radio button option next to “E-Commerce Website:” and then click the “Save Changes” button.
Now, and only now, you are ready to start tracking e-commerce transactions at your online store.
In my new workbook titled “Google Analytics Uncovered for Zen Cart: The Workbook“, to be released on or before August 15th, 2007; I go into even more detail about how to install, read, and utilize Google E-Commerce tracking for Zen Cart. Keep an eye out for that.
With close to 100 pages of content, it’s sure to provide a wealth of unknown information and uncover some revealing details to help you read and understand what your Google Analytics are telling you. This information, when used properly, can assist you in increasing conversion of your website.
**** UPDATED 7/30/07 ****
I’ve had a number of users ask to show the Zen Cart customized code that should be used if you are planning on inserting it by hand (and not electing to use the Simple Google Analytics contribution; my recommended method). So, to help those users out, I have included instructions and code below to achieve that.
To insert the code for e-commerce tracking into Zen Cart by hand, you will need to alter two different files.
The first file you will need to alter is:
/includes/[your_template]/templates/common/tpl_main_page.php
Find that file, and insert the following code into it just above the closing
It would be very helpful if you were to put the actual values that Zencart uses into the ecommerce code you have listed. I didn’t get the Analytics module to work for ecommerce, so I ended up going into my database to find the correct id’s for the code and then inserting the code into a footer banner.
Just a suggestion :o) I am looking forward to your ebook. I have utilized the recommendations from your blog and have seen great results! Thanks for all you do…
Amy
Amy,
Are you using the Simple Google Analytics Contribution?
If you are, then e-commerce tracking is already installed with it.
If you are not using that, and are doing it by hand, then you will need to alter 2 different files to get it to work with Zen. You’ll need to edit:
/includes/[your_template]/templates/common/tpl_main_page.php
and
/includes/modules/pages/checkout_success/header_php.php
Glad that you have found success by implementing my continued suggestions on this site. I only post what I have already tested and have found to work.
I’m constantly testing and re-testing new options. As I find those that work, I like to let others know.
So do we just enter this code without any modifications?
UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity]
Or do we need to alter it to fit our set up? Also, based on your comment above, we also need to edit the main page and header template file? I thought it was just the checkout_confirmation page that got this e-commerce tracking code.
Ben,
I have edited this post and updated it with the code you should use if you are manually inserting e-commerce tracking into Zen Cart.
Keep in mind that if you are using the Simple Google Analytics module for Zen Cart, you should not have to insert code by hand at all to install e-commerce tracking. That is automatically done for you when you install the module.
Hi Eric,
Thank you for your wonderful help! It’s really helpful, especially if you are a new Zenner like me.
I came upon your site right after I implemented a GA tracking which was suggested by “ses707” on Zen forum:
http://www.zen-cart.com/forum/showpost.php?p=159558&postcount=33=
Does the solution provided on Zen forum achieve the same results?
I would have loved to use the Simple Google Analytics module but it is for v1.3.6 and I’m running v1.3.7
Thank you for the help!
It looks similar, however, since I have never used that exact code, in the places they mentioned, I can’t for sure say.
I can say that that solution does not include Conversion Tracking.
The Simple Google Analytics module works just fine on 1.3.7 (I’m using it on a few sites running 1.3.7 right now). Anything over 1.3.6 it works with. I even think it works on 1.3.5.
I am sure that most people figured it out, but for a newcomer it may not be so obvious. Here were your original instructions:
/includes/[your_template]/templates/common/tpl_main_page.php
Should it not have been:
/includes/templates/[your template]/common/tpl_main_page.php
Also the latest download (1.1.1) from the Zen Cart site does not have the files already modified so I had to do the manually config instructions. My current version of ZC (1.2.6 I believe) did not have $zv_order_total_cd = $orders->fields[’order_total’]; or the other type of code. You may want to say you need to copy and paste this line (if you do not have it) at the beginning of the instructions instead of the end.
Just some thoughts :o)
Shawn
On December 13 2007, Google updated Analytics to use ga.js instead of using urchin.js. See the following post: Google Analytics ga.js. How does this affect integration of ecommerce tracking for Zen Cart?
Google shows a way to do this manually for any shopping cart system: http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55528, but it seems there should be a plugin out there that would make integration with ZenCart even simpler.
For Zen Cart, I have already developed the updated plug-in using that replaces the “urchin” code with the updated “ga” code. It is set for release here later today or tomorrow.
Do you know if the tracker can recieve null data and still work?
pageTracker._addTrans(
"",
"",
"{$order.grandtotal|commify}",
"{$order.taxtotal|commify}",
"{$order.shiptotal|commify}",
"{$info.billing.billing_city}",
"{$info.billing.billing_state}",
"{$info.billing.billing_country}"
);
It won’t “break” the tracking outright. It will cause some strange figures in your e-commerce reports with regard to sales figures, product info. etc…
Why would you ever see a “null” transaction? If you sold a product, the transaction should include the data relating to that product.
The current commerce engine we are using doesn’t track order id numbers so that field would be null. I could place some arbitrary data in there if it meant actually getting some results on my e-commerce reports. Currently we have had absolutely no success with it. Here is a sample of what should be a tracked transaction:
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._initData();
pageTracker._trackPageview();
pageTracker._addTrans(
"",
"",
"79.89",
"4.95",
"14.95",
"Burbank",
"CA",
"United States"
);
pageTracker._addItem(
"",
"41305",
"Leather Curved Focus Mitts with XL Hand Cage",
"",
"59.99",
"1"
);
pageTracker._trackTrans();
Robin,
I see. You’ll have a tough time getting accurate results for ecommerce without a unique product id.
Entering arbitrary info into that field won’t do a whole lot of good either unless, that information remains consistent and does not interfere with a later “arbitrary” number.
If your current ecommerce engine doesn’t track order id numbers, then how do you keep track of orders? What’s to prevent one from interfering with another?
I would take a careful look at your current ecommerce system if it does not track order ids. if you plan on expanding and growing, that could cause a problem in the future.
Just a few thoughts.
Thanks Eric… just a follow up. I am still not getting any data in the reports at all. Accurate or not there is nothing coming through for the E-Commerce content. Is there anything wrong with what you see above that could indicate such a lack of content?
With the exception of the initial “transaction” id, the code above looks ok.
Have you turned on E-Commerce tracking for your Google Analytics Profile?
If you haven’t done that yet, then it won’t track ecom data no matter how good the tracking code is?
Hi, could we know the navigation information before the transaction? I mean for each transaction, could we know the pages been visited before the purchases and the average time spent?
Thanks!
This is what is called the “click path”. There are analytics systems that allow you to look at this but currently Google Analytics doesn’t have an effect method of doing so.
IndexTools did a great job of this. They have been purchased by Yahoo! and it looks like they still have this ability.
You may want to consider that as a secondary solution to Google Analytics (you can install both simultaneously.)
A link to some of the features of Yahoo! Web Analytics can be found here:
http://web.analytics.yahoo.com/features.php
Hi,
I’ve tried your google analytics contribution and then tried hand code since some of the files seem to be in different directories (I’ve inherited this Zen store and am still learning about Zen Cart). Everything is showing up zeros at google and I’m getting this error message at the base of my success page. What am I missing??
thanks in advance!
var pageTracker = _gat._getTracker(“UA-XXXXXX-X”); pageTracker._initData(); pageTracker._trackPageview();
Fatal error: Call to undefined method queryFactory::bindVars()
Sandy,
It sounds like something else was altered when you tried to install this mod. It should have no issues as such that I am aware of (or that any others have reported).
I’ve installed the simple google mod, and the analytics are working great, but the conversion tracking is not registered. The option to input my conversion tracking number shows up, so I think the mod is installed correctly, but I’m getting no conversions on my adwords account. I’m got it turned on correctly and it is receiving data. Is there anything I need to do besides input my conversion tracking number into the option field in zen cart?
You need to make sure you are using the right tracking number (different from the analytics number and found within your Adwords account.) Conversion tracking is used in conjunction with Adwords / Paid Search data. If you have the right conversion tracking number and you have turned on conversion tracking from within your Adwords account, you should see numbers.
Hello,
I installed the “Simple” code and conversion stats works great, but unfortunately, my “normal” Google Analytics stats have doubled. I took a look at source of my homepage, and the Google Analytics code is twice in it… (see below).
I installed a Simple mode code through admin section, so how (and from which file) can I now delete the repeating part of the code?
Thanks,
Nikola
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
var pageTracker = _gat._getTracker(“UA-3682829-8”);
pageTracker._initData();
pageTracker._trackPageview();
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
var pageTracker = _gat._getTracker(“UA-3682829-8”);
pageTracker._initData();
pageTracker._trackPageview();
If your stats doubled then the most likely cause is that you have two instances of Google Analytics installed on your site (which is confirmed by the lines of code you referenced.)
You’ll need to remove one of those in order for it not to double track stats.
The most common cause of this double tracking issue within zen cart is that someone manually entered the analytics code on pages of the site (footer, etc…) and when you installed the Simple Google Analytics module you did not delete that previously hand added code.
Delete that previous reference to GA and leave the Simple GA module running and you should see normal stats again.