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