Google Analytics Demystified: Part 3 – E-Commerce Tracking

July 28, 2007 by Eric  
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>
</form>

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.

<?php
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'];
}
}
?>
</textarea>
</form>

<?php
} //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:
/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.

Google Analytics Demystified: Part 2 – Vanilla Google Analytics

July 18, 2007 by Eric  
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="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-xxxxxx-x";
urchinTracker();
</script>

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

http://www.yourwebsite.com (Incorrect URL Structure)
http://www.yourwebsite.com/ (Correct URL Structure – with the trailing slash “/”)

http://www.yourwebsite.com/store (Incorrect URL Structure)
http://www.yourwebsite.com/store/ (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 Eric  
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:

admin/shipping_export.php

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.

Google Analytics Demystified: Part 1 – The Introduction

July 10, 2007 by Eric  
Filed under Website Analytics

Google AnalyticsThere seems to be so much confusion with understanding Google Analytics that I thought it would be appropriate to devote a special series to it.

Once I uncover the mystery surrounding its power, you’ll forever wonder how you lived without it.

Throughout the series, I’ll reveal the proper way to install Google Analytics and explain what it can tell you once it has been successfully completed.

I’ll also uncover the mystery surrounding its 4 main components including:

  • “Vanilla” Google Analytics Tracking
  • E-Commerce Tracking
  • Conversion Tracking
  • Goal Tracking (including Sales Funnels)

Together they all play an important part in the entire “statistics overview”, yet each one can operate independently of the other. As such, each one also has their own unique and separate tracking code that needs to be installed if you plan to use it. Simply installing “Google Analytics” will not install E-commerce Tracking, nor will it install Conversion Tracking or Goal Tracking. These are separate entities within the entire analytics package.

Ok, so now that I have pointed that out, let me explain the difference between the 4 main components.

“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 things like “where your visitors are coming from”, “what type of browsers they are using”, “how many 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="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-xxxxxx-x";
urchinTracker();
</script>

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 “Vanilla” 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>
</form>

Google Conversion Tracking

If you are running any Paid Search (PPC) campaigns (especially through Google Adwords), then you will want to install Conversion Tracking to determine how effective those campaigns are at increasing conversion, and generating sales.

Conversion Tracking reports things such as “How effective your Adwords ads are”, “which actual keywords convert to sales, and which just cost you money”, “overall conversion rate for a campaign, ad, or group of keywords”, and more.

The code you use to install Google Conversion Tracking looks something like this and is placed on the sales RECEIPT/CONFIRMATION page. This is the page a user arrives at after completing a successful sale (checkout) at your store.

Sample of Google Conversion Tracking Code:

<script language="JavaScript" type="text/javascript">

</script>
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0 src="https://www.googleadservices.com/pagead/conversion/ xxxxxxxxxx/?value=0.00&label=purchase&script=0">
</noscript>

Google Analytics Goal Tracking

Goal Tracking gives you the ability to track important events (actions/goals) that users take when they visit your site.

These Goals can range from simply filling out a contact form, to downloading a free brochure, to an actual sale that generates revenue. The choice is yours, but choose wisely. At the time of this writing, Google only allows you to track up to 4 total goals. I would choose those that have the biggest impact on the success of your business.

Unlike the first three components that are available to us in Google Analytics, the Goal Tracking component does not require any special code other than the “Basic” Analytic Tracking code that I showed you in the previous post. The thing is, as with most of the Google Analytics Tracking elements, this one relies on more than just “installation of tracking code” to get it working.

You can enhance Goal Tracking even further, to produce more powerful report data by creating what is called a “Funnel” to that Goal. By doing this, you will now be armed with the tools necessary to find out how effective the process leading up to an individual Goal really is. You will discover what flaws exist in the channel and where they are. In short, this will help you determine many things including, exactly at what point in your sales path users are abandoning the process. And as we all know, that is a critical element you need to know if you are to increase conversion.

The Introduction is Complete. Now On With the Show!

Ok, so I have introduced you to the 4 components that make up “Google Analytics”. The remaining parts of this series will go into more detail on each of the 4 pieces, explain how to set each up, give examples of such, and uncover how you can harness their collective power to help increase your conversion.

Until next time; keep the traffic flowing, and the analytics recording.

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

Part 2 of this series discusses “Vanilla” Google Analytics including setup and troubleshooting for installation.

Are You Losing Google Page Rank Because You Forgot the WWW?

July 2, 2007 by Eric  
Filed under E-Commerce Optimization

There are many reasons why you should remain consistent with your naming conventions on the Internet, especially when it comes to your domain name.

One reason is for the dreaded “duplicate content” hit you might take with a site that is indexed with both the “www” and the “non-www” form of the domain name. Another, and the one I will focus on here is the fact that you could be cheating yourself out of higher Page Rank from Google by actually “splitting it across two domains”.

What do I mean by “splitting” Google Page Rank?

Google Page RankFirst off, let me explain in short what Page Rank really is. “Page Rank” really is a measure of the incoming links to your website. Also understand that just “getting links” is not going to necessarily increase your Page Rank. The links must contain relevant content to what you offer in order to give you the most benefit. Naturally speaking then, it would make sense that the more relevant links you have coming to your website (from other similar sites), the higher your Page Rank will be.

Ok, now that we got that out of the way, let me present you with the following.

Have you ever noticed that when you go to your site using a url like http://www.yoursite.com (with the “www”) you see your Google Page Rank as one number (out of 10) and when you view your site as http://yoursite.com (without the “www”) you see a different Page Rank number (out of 10)?

Or, have you ever performed a Google search for your site as follows on http://www.yoursite.com and on http://yoursite.com and noticed that you are indexed by Google under both the “www” variation and the “non-www” variation?

If so, you are a victim of Canonical naming conventions at work, and you could be losing Page Rank because of it.

Why is this important and what does it all mean? Well, it’s important because if you want to follow better Search Engine Optimization (SEO) practices, and get maximum benefit of your possible total Page Rank, then you need to pay attention to the way your site is indexed.

What does it mean? I’ll give you an example of what it can mean to you (for illustrative purposes only.) If your site has a possible (or potential) total Page Rank of 6 out of 10, and you are indexed with both the “www” and the “non-www” form of your domain name, then your Page Rank could be split to just 3 out of 10!

Much different than a 6 out of 10 right?

So how could it be just 3 out of 10 when its full potential is 6? Well remember, in our example, Google has you indexed as “2 different domains” (by Canonical naming conventions) even though you are the same website. Google has to allocate the incoming links to your site and give them a Page Rank accordingly so it “splits the links” across the two different domains. This split is not always “50 / 50″, but in our example I use that for ease of understanding.

It takes the portion of the links that point to your site’s “www” form (www.yoursite.com) and gives them a portion of the total Page Rank. It then takes the remaining links that point to the “non-www” form (yoursite.com) of your domain name and allocates them a Page Rank. This example assumes that 50% of the incoming links point to one domain form, and 50% to the other form.

Now does it make more sense? Google took the possible “6 out of 10″ Page Rank and split it into two equal halves of “3 for one domain”, and “3 for the other domain form”.

The result — instead of having a Page Rank “6 out of 10″, you now have a Page Rank “3 out of 10″.

You can’t control how others link to you (the “www” vs. “non-www” form of your domain — although you can try), but you can control what happens once they arrive at your site.

So you know you are a victim, what can you do to fix it?

In a previous post I talked very briefly about how I used a 301 redirect to move content from my old site to this; then new, domain.

You can use the same concept to redirect requests from your “non-www” domain to your “www” domain and vice versa. Just be consistent with which version you choose.

Quickly, let me show you one more example to demonstrate what the proper setup for your site gets you. In this case, I’ll use my domain (zencartoptimization.com).

The following are two examples that get you the same “common” end result.

Click on http://www.zencartoptimization.com/ (a new window will open). What do you see in the address bar of your browser? You should see the “www” version of the domain name.

Now, click on http://zencartoptimization.com/ (a new window will again open). What do you see this time in your address bar? Right! You again should see the “www” version of the domain name even though the link points to the “non-www” version!

So now we have “Canonical naming” consistency and our Google Page Rank will be combined into one final value.

Now, try the same thing for your own site. Type it with the “www” and without the “www”. See what end result you get.

If you do not get a consistent result (either both “www” url’s in the end or both “non-www” url’s in the end — whichever route you choose,) then you may want to consider adding a few lines of code to your .htaccess file (make sure it is located in your website’s root directory) to correct the situation.

Dynamic 301 Redirects Correct the www/non-www Canonical Issue

If you use the www version use this code

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomainhere(.*)
RewriteRule ^(.*)$ http://www.yourdomainhere.com/$1 [R=301,L]

If you are using the Zen Cart Search Engine Friendly URLS Contribution, this still can be added as well (it’s not automatically included in the module, you have to add it yourself). In that case, you simply add the following to the bottom section of the .htaccess file that came with the module install.

RewriteCond %{HTTP_HOST} ^yourdomainhere(.*)
RewriteRule ^(.*)$ http://www.yourdomainhere.com/$1 [R=301,L]

The code above will 301 redirect the non-www version to the www version. Remember to replace “yourdomainhere” with your own domain name.

If you use the non-www version use this code

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomainhere.(.*)
RewriteRule ^(.*)$ http://yourdomainhere.com/$1 [R=301,L]

The code above will 301 redirect the www version to the non-www version. Remember to replace “yourdomainhere” with your own domain name.

So now you should know why it is important to be consistent in your naming conventions. A slight oversight could be costing your Zen store valuable Page Rank.

Got a different method to achieve the same effect? Let me know.