osCommerce part III – Analysis (the good stuff)
December 14, 2006
First of all, my apologies on the delivery of this article. Life’s been fairly hectic. Moving on…
Now that you have a fully functional ecommerce store up with osCommerce, how can the store make more money? The key is to learn the most you can about your customers. The most eye opening experience I had in Kansas City: a well targeted advertisement can go a long way. Targeting is the hard part.
At the end of this tutorial you should be able to answer these questions:
- What products should we advertise to whom?
- Where are my buyers coming from? (Geographically/Internet Referrals)
- What products am I selling the most?
- What is my average order value?
- What is my store’s conversion rate? (What percentage of my visitors are becoming customers?)
If you’re using Google AdWords in a PPC campaign…
- What is my campaign ROI?
- Which keywords have the highest conversion rate?
- Which keywords should I stop?
Luckily, all of the data analysis has been done by Google/Urchin engineers. We just have to fit our store to their specifications. I’ll get to that later.
In an online store there is a point in a checkout process called a *“conversion point”*. A typical checkout process goes like this:
- Enter Shipping / Billing Information (checkout_shipping.php)
- Enter Payment Information (checkout_payment.php)
- Verify Order Contents (checkout_confirmation.php) -> (checkout_process.php)
- Yay! Smiley! Your order is complete. Thank you emails and invoices can be sent from this point, too. (checkout_success.php)
Point #4 is the conversion point. The order is complete. The visitor to the site is now a customer. This is a very important transformation for analysis. In osCommerce, this page is checkout_success.php.
Unfortunately, osCommerce ditches the $order object’s contents (presumably for security reasons) in checkout_process.php. At the top of checkout_process.php I added a line:
$_SESSION[‘orderData’] = serialize($order);
Since we’re using session based variables we have to serialize the object and unserialize the object. I won’t get into why we have to do that here…
So now, on checkout_success.php we can access our $orderData object like this:
$orderdata = unserialize($_SESSION[‘orderData’]);
We need the contents of the $orderData object to pass to Google Analytics.
The way Google Analytics works:
- Constructs an amazingly long URL with Browser Data
- Compiles the data and makes pretty graphs at Google
Google Analytics has a good guide in regards to code to add to checkout_success.php.
Basically, the lines that start with UTM:T are transactions and UTM:I are items within the transaction. Just loop through your $orderData object and fit your data to Google’s syntax. It’s that simple. Now watch the money come in…
Google Analytics’ ecommerce tracking takes care of the heavy lifting for you.
Revenue by Transaction
Revenue By Source
The answers to all of the questions posed at the beginning of this article can be found in Analytics’ Ecommerce section. Check out the other articles in this series: