Google Analytics Demystified: Part 3 – E-Commerce Tracking

July 28, 2007 by  
Filed under Website Analytics

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:

<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity] </textarea>

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:

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.

if ($_GET['main_page']=="checkout_success") { // if transaction is a successful purchase then record the order details

<body onLoad="javascript:__utmSetTrans()">
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|<?php echo $zv_orders_id ?>||<?php echo $zv_order_total_cd ?>|<?php echo $zv_order_tax ?>|0.00|<?php echo $zv_order_city ?>|<?php echo $zv_order_state ?>|<?php echo $zv_order_country ?>
<?php // Loop through products purchased to track in Google (these come from the "cart_orders_products TABLE)
//sku = "products_model"; productname = "products_name"; category = ""; price = "final_price"; quantity = "products_quantity"
$products_displayed_google = array();
for ($i=0, $n=sizeof($products_array_google); $i<$n; $i++) {
if (!in_array($products_array_google[$i]['id'], $products_displayed_google)) {
echo 'UTM:I|' . $zv_orders_id . '|' . $products_array_google[$i]['model'] . '|' . $products_array_google[$i]['text'] . '||' . $products_array_google[$i]['price'] . '|' . $products_array_google[$i]['quantity'];
$products_displayed_google[] = $products_array_google[$i]['id'];

} //End if for adding e-commerce tracking code.

The second file you will need to find and edit can be found in the following location:

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']);
//*************************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.

Google Analytics Demystified: Part 2 – Vanilla Google Analytics

July 18, 2007 by  
Filed under Website Analytics

Google Analytics

In Part 1 of this series, I summed up the various components that make up Google Analytics. In Part 2 here, I will go into what makes up the foundation for Google Analytics. I like to call it “Vanilla” Google Analytics.

“Vanilla” Google Analytics Tracking

The “typical form” of a Google Analytics install is what I like to call the “Vanilla” (or plain) version. It is the one that you are given tracking code for by default when you create a Google Analytics account.

“Vanilla” Google Analytics Tracking is used to track typical patterns you would expect to see with most “statistical tracking packages”. You’ll get information on things like where your visitors are coming from, what type of browsers they are using, how many unique visitors came to your site, etc…

The code you use to install Google Analytics looks something like this and is usually placed near the bottom of every page you want to track information for. It’s the tracking code that starts with “UA-” at the beginning.

Sample of “Vanilla” Google Analytics Tracking Code:

<script src="" type="text/javascript">
<script type="text/javascript">
_uacct = "UA-xxxxxx-x";

This code is given to you by Google upon successful sign up of your Google Analytics account. Keep in mind that the “xxxxxx-x” shown in red above should be replaced with the unique tracking id Google assigns to your Analytics account.

Also keep in mind that if you are using an open source shopping cart like Zen Cart, there are third party modules already built that you can install, which make the process of installing the tracking code easier.

In many cases, after installing the third party module, all you need to do is to enter your unique Google Analytics ID into the configuration section of the admin. You can download Simple Google Analytics, one third party module, that will make it a bit easier to install Google Analytics Tracking code on your site.
Google Analytics Zen Cart Configuration

Important Note:
Although the above information will install the tracking code on your web site, it will not necessarily “activate” tracking for it.

In order to activate tracking for Google Analytics, you must now login to your Google Analytics account and click on the “Check Status” link provided for the site you have installed the tracking code on.
Google Analytics Not Installed Message

Once you click on the “Check Status” link, Google will go out to your website and verify that the tracking code is installed correctly. If it is installed properly, and you have given the proper URL to verify it, then you should get a screen that looks like the following.

Google Analytics Waiting for Data Message

I followed the instructions and am still getting a “Tracking Not Installed” message – what did I do wrong?

If you still get a message saying “tracking code not installed”, or “unable to verify tracking code”, then you need to carefully check a few things and try again.

  1. Check that that tracking code is actually in place on your site near the bottom of the page (top will work if needed, but bottom is desired).

    The easiest way to do this is to view your website in the browser of your choice. Then perform a “View Source” of the page you are on. Now, scroll to the bottom of your page, and check for code that looks similar to that which has been present earlier in this post. If the tracking code is in place, and contains your unique Google Tracking ID (in place of the “xxxxxx-x”) then you have “passed” this first test.

  2. Make sure you carefully check the URL that you told Google to verify the code at. Google can’t verify the code exists if you give it the wrong URL to check.

    Special Note: Make sure you do not forget the trailing slash (“/”) at the end of your URL or Google may have problems verifying the code exists. An example of what I am talking about is below for reference.

Examples of proper URL’s to give Google for verifying tracking code exists (Incorrect URL Structure) (Correct URL Structure – with the trailing slash “/”) (Incorrect URL Structure) (Correct URL Structure – with the trailing slash “/”)

OK, if you have followed everything I presented here, you should have what I call “Vanilla” Google Analytics Tracking in place and verified on your site. You have the “Waiting for Data” message, and are ready to move on with the installation of the other components that make up Google Analytics.

For more detailed information on how you can use Google Analytics to increase conversion of your website, be sure to check out Google Analytics Uncovered for Zen Cart: The Workbook..

In the next Part 3 of the series, I will discuss the E-commerce tracking component of Google Analytics.

Still having problems with Part 2? Contact me and we’ll work through it.

NEW RELEASE: Export Shipping and Order Information v1.2.2 Contribution

July 13, 2007 by  
Filed under Zen Cart Contributions

This Version 1.2.2 is a Bugfix release. Two reported issues are addressed in it.

Bugfixes Included in Version 1.2.2

  1. Bugfix: Corrected “table not found” error message when exporting all attributes / 1 product per row
  2. Bugfix: Corrected placement of Zip code and State fields in export.

How to Download Version 1.2.2
You can download this new version by clicking here. You will be taken to my downloads page where you can select the new 1.2.2 version.

Upgrading from version 1.2.1

If you are upgrading from version 1.2.1 all you have to upload is the following file:


No other files have changed since the last release.

Upgrading from versions prior to 1.2.1
For those of you upgrading from a version prior to 1.2.1, simply overwrite all files from the previous version when asked. That’s all.

Next Page »