Yes, there is a working Google Analytics/Virtuemart.
I hope this response is in the right place. I spent a couple of days researching how to take advantage of Google Analytics Goal Conversion tracking through the Virtuemart checkout process and I have found a solution that works for me. I am hoping it works for others?
First let me thank the dozens of posts across various topics associated with Joomle/Virtuemart and Google Analytics. No single post gave me the complete answers I needed but by piecing together advice and recommendations for a number of posts I was able to come up with something that works.
I am using Joomla 1.5.15 with the RocketTheme Mynxx template designed for Virtuemart, and Virtuemart 1.1.3 stable.
Step 1: Get Google Analytics working with your Joomla installation. Sign up for Google Analytics and go through their process for acquiring your unique tracking code. If you don't know how to do this go to:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=66983&cbid=1p8mooumxqh3h&src=cb&lev=index and follow their directions.
Once you have your site registered and have acquired your tracking code you need to install it in your Joomla Template. This is a step that is specific to the template you are using with Joomla/Virtuemart. Since I am using Mynxx this example will also - you will need to map these instrustions to your specific template.
In your Joomla installation locate and open the file templates/rt_mynxx_j15/index.php.
Add your tracking code to the end of the index.php file just before the </body> tag. Example (Note: The comments in the code are mine):
<!-- BEGIN Google Analytics Code Part 1 -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<!-- END Google Analytics Code Part 1 -->
<!-- BEGIN Google Analytics Code Part 2 -->
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-nnnnnnnn-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!-- END Google Analytics Code Part 2 -->
Upload your updated index.php file and you should now have the basic Google Analytics tracking setup properly. Keep in mind it can take Google a few hours to validate that tracking code is installed correctly so you may have to wait.
Once you are comfortable that the basic Google Analytics tracking code is working properly (after a day or two of tracking site visits) then you can move on to the next step - Adding Goal Conversion tracking.
Step 2:
You are going to have to edit a few Virtuemart files in this next section - Please - make backup copies of each of the files mentioned before editing them. It's always good practice.
This article from Google is a good reference for what is about to be explained next:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55576 It will outline how to create "virtual" URLs to be used specifically for tracking Goal Conversions and the associated Goal "funnel".
Step 2-A. Move the first Google Analytics Script file to the <head> section of your index.php file. You want the first part of the script to be loaded first on the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<!-- BEGIN Google Analytics Code Part 1 -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<!-- END Google Analytics Code Part 1 -->
Leave the second part of the Google Analytics script where it is - just before the </body> tag.
Note: this isn’t normally recommended by Google since if there is a problem loading the GA script from Google your site may display slowly or not at all but to date I haven’t had a problem – just be aware if you start experiencing performance or page load errors.Step 2-B: Locate and open the file: administrator/components/com_virtuemart/html/checkout.thankyou.php. This is the php that executes to display the successful "Thank you for ordering" VM page.
At the end of this file, just before the closing php tag "?>" place the following code:
echo '<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-nnnnnnnn-1");
pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");
} catch(err) {}
</script>';
It is a slightly modified "2nd part GA Script". Note that "var pageTracker" is changed to "pageTracker_co" and the line after that is changed to "pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");"
Please take special note that this entire script string is output via "echo" at run time by the php script. If you simply paste in the GA tracking code without making it an echo'd string it won't work.
This creates a different instance of the GA tracker that will send GA a page hit on "/funnel_Cejay1/checkoutComplete.html". This is the page that is my target "Goal" URL. Refer to Google help for setting up your GA goals and funnels.
Step 3: Setting up a funnel.
Using the same approach we used in Step 2-B we are going to add similar GS tracking code to the following files: They are all located in:
components/com_virtuemart/themes/"YourTheme"/templates/checkout
get_shipping_address.tpl.php
get_shipping_method.tpl.php
get_payment_method.tpl.php
get_final_confirmation.tpl.php
These php scripts output a page for each of the checkout steps in VM - you know, the ones that all have the URL of index.php.
As with the checkout.thankyou.php modifications above you will edit each of these files and place a slightly modified GA script in each to output when the page loads. NOTE: In these files you do not need to use the "echo" function. You can simply paste the GA script.
Open and edit get_shipping_address.tpl.php placing the following at the end of the file.
<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-nnnnnnnn-1");
pageTracker_co._trackPageview("/funnel_Cejay1/getShippingAddress.html");
} catch(err) {}
</script>
What's important, and different, here is the virtual URL "/funnel_Cejay1/getShippingAddress.html"
You can actually call this anything you like as long as you use something different for each step. When this page is loaded it will send GA tracking the URL "/funnel_Cejay1/getShippingAddress.html". And this is the first step in our checkout process funnel.
I won't show each of the other three file modifications - they are virtually identical except for what you call the virtual URL.
That's it - at least I believe I covered all the necessary steps. If I had more time I would have done a more thorough step-by-step. I hope I didn't forget anything.
Feel free to contact me if you have any questions. I will try to help time permitting.
Thanks again to all that came before me, each adding their piece of this puzzle.
Mike