• Skip to main content
  • Skip to primary sidebar

Zen Cart Optimization

Practical How To's for Increasing Ecommerce Sales

  • Home
  • Categories
    • Blogging
    • Conversion
    • Customer Retention
    • Design & Usability
    • E-Commerce Optimization
    • Email Marketing
    • Featured
    • Marketing Strategies
    • Marketing Strategies
    • Mobile Commerce
    • Podcasts
    • Search Marketing
    • Shopping Cart Abandonment
    • Social Media
    • Website Analytics
    • Zen Cart Google Analytics
    • Zen Cart Optimization
    • Zen Cart Recurring Billing
You are here: Home / Website Analytics / Google Analytics Demystified: Part 3 – E-Commerce Tracking

Google Analytics Demystified: Part 3 – E-Commerce Tracking

by Eric Leuenberger 23 Comments

Google AnalyticsIn 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.

Important Note:
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.

Google Analytics E-Commerce Tracking

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.

Google Analytics E-Commerce Tracking

At this final screen, simply select the “Yes” radio button option next to “E-Commerce Website:” and then click the “Save Changes” button.

Google Analytics Enabling E-Commerce tracking

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 tag, but below the “Vanilla” Google Analytics Tracking code. It is important that this code goes below the original tracking code Google Analytics provides, or it will not work correctly.







The second file you will need to find and edit can be found in the following location:
/includes/modules/pages/checkout_success/header_php.php

Add the following lines of code to that file.

Take Note, for older versions of Zen Cart, you will want to add this code just below the following line:

$zv_order_total_cd = $orders->fields[‘order_total’]; (approximately line # 74.)

On newer versions the line you would want to add it below looks like this:

$orders_id = $zv_orders_id; (approximately line #54.)

Here is the code you’ll want to insert.


// Added the below field for Google Analytics E-commerce Tracking
$zv_order_tax = $orders->fields['order_tax'];
$zv_order_city = $orders->fields['delivery_city'];
$zv_order_state = $orders->fields['delivery_state'];
$zv_order_country = $orders->fields['delivery_country'];

// Google Analytics Tracking (This can be removed and not harm anything)
//Altered code below to accomdate additional fields that Google Analytics can Track
$products_query = "select products_id, products_name, products_model,products_price, products_quantity from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . $zv_orders_id . "'
order by products_name";
$products_google = $db->Execute($products_query);
//********************Google codes**************************
while (!$products_google->EOF) {
$products_array_google[] = array('id' => $products_google->fields['products_id'],
'text' => $products_google->fields['products_name'],
'model' => $products_google->fields['products_model'],
'price' => $products_google->fields['products_price'],
'quantity' => $products_google->fields['products_quantity']);
$products_google->MoveNext();
}
//*************************End Google Codes*******************
// End Google Analytics Code

Finally, make sure you also include the following line (to get the order total) if it is not already present as well.


$zv_order_total_cd = $orders->fields['order_total'];

That should help those who want to add the code by hand. Any questions. Let me know.

For more detailed information on how you can use Google E-Commerce to increase conversion of your website, along with full disclosure of how it can integrate with your Google Analytics account for even more powerful reporting capabilities, be sure to check out Google Analytics Uncovered for Zen Cart: The Workbook..

Part 4 of this series delves into the use of Conversion Tracking for Google Analytics to help increase your conversion.

Filed Under: Website Analytics

About Eric Leuenberger

Eric Leuenberger is an ecommerce marketing expert and author. He coaches store owners using his online coaching system Ecommerce Amplifier teaching them how to increase website sales using his proven six step process.

Reader Interactions

Comments

  1. Amy McCoy says

    July 29, 2007 at 5:04 pm

    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

    Reply
  2. econcepts says

    July 29, 2007 at 10:51 pm

    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.

    Reply
  3. Ben says

    July 30, 2007 at 8:48 am

    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.

    Reply
  4. econcepts says

    July 30, 2007 at 1:01 pm

    So do we just enter this code without any modifications?

    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.

    Reply
  5. Skye says

    August 2, 2007 at 7:41 am

    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!

    Reply
  6. econcepts says

    August 2, 2007 at 11:30 am

    Does the solution provided on Zen forum achieve the same results?

    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.

    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

    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.

    Reply
  7. Shawn says

    September 11, 2007 at 12:10 pm

    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

    Reply
  8. AJ says

    January 11, 2008 at 7:00 pm

    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.

    Reply
  9. econcepts says

    January 13, 2008 at 11:10 am

    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.

    Reply
  10. Robin says

    February 18, 2008 at 5:03 pm

    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}"
    );

    Reply
  11. Eric Leuenberger says

    February 18, 2008 at 7:15 pm

    Do you know if the tracker can recieve null data and still work?

    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.

    Reply
  12. Robin says

    February 26, 2008 at 2:00 pm

    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();

    Reply
  13. Eric Leuenberger says

    February 26, 2008 at 7:23 pm

    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.

    Reply
  14. Robin says

    February 26, 2008 at 9:15 pm

    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?

    Reply
  15. Eric Leuenberger says

    February 27, 2008 at 8:10 pm

    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?

    Reply
  16. Jinqiu says

    September 26, 2008 at 6:31 am

    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!

    Reply
  17. Eric Leuenberger says

    October 17, 2008 at 6:50 am

    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

    Reply
  18. Sandy says

    October 20, 2008 at 1:07 pm

    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()

    Reply
  19. Eric Leuenberger says

    November 21, 2008 at 2:43 pm

    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).

    Reply
  20. Matteson Perry says

    December 3, 2008 at 7:44 pm

    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?

    Reply
  21. Eric Leuenberger says

    December 10, 2008 at 8:54 am

    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.

    Reply
  22. Nikola says

    June 30, 2009 at 5:38 pm

    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();

    Reply
  23. Eric says

    July 1, 2009 at 10:18 am

    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.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Sponsors

MemberPress Wordpress Membership Site Plugin

Categories

  • Articles
  • Blogging
  • Breaking News
  • Conversion
  • Customer Retention
  • Design & Usability
  • E-Commerce Optimization
  • Email Marketing
  • Featured
  • Marketing Strategies
  • Mobile Commerce
  • Search Marketing
  • Shopping Cart Abandonment
  • Social Media
  • Uncategorized
  • Website Analytics
  • Zen Cart Contributions
  • Zen Cart Optimization
  • Zen Cart Recurring Billing

Copyright © 2023