Adding Google Analytics E-Commerce Tracking to WP E-Commerce

Over in the Instinct support forums I’ve been contributing towards implementing Google Analytics E-Commerce Tracking support for WP E-Commerce, I made some progress and am sharing my work below.

My solution only notifies Google Analytics of ‘successful’ transactions and does not support, as yet, the following:

  • total tax
  • state details
  • failed or abandoned sales

Note: This is an intermediate patch requiring PHP and limited phpMyAdmin knowledge, if you’re unsure of anything mentioned below I can install this for you, contact me for more details.

Instructions

  1. Backup transaction_result_functions.php within /wp-content/plugins/wp-e-commerce/ as you will need the original if anything goes wrong.
  2. Open transaction_result_functions.php with your favourite text editor
  3. On line #288, immediately after if($sessionid != null){ paste the contents of my patch
  4. On line #298 replace the Google Analytics tracking ID (e.g. UA-########-#) to your own
  5. Save changes

Test your new Google Analytics E-Commerce Tracking integration by successfully performing a live purchase and viewing the source code of the Transaction Results page, it should look similar to my sample below.

try {
var pageTracker = _gat._getTracker("UA-########-#");
pageTracker._trackPageview();
pageTracker._addTrans(
"3",
"Visser Labs",
"1.00",
"0.00",
"0.00",
"Mountain Creek",
"",
"AU"
);
pageTracker._addItem(
"3",
"0000000001",
"Assassin's Creed II",
"Xbox 360",
"1.00",
"1"
);

That’s it. In later versions I will add an Administrator interface and/or package this as a plugin for WP E-Commerce.

Download

Google Analytics E-Commerce Tracking for WP E-Commerce

Leave a Comment

Before you comment - Do you have a support request? If so, this is not the right place to post it. Please submit support requests for Premium Plugins on the Support page and in the community Support Forums for free Plugins.

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