Virtuemart and Google Analytics Goals
If you are using the content management system Joomla, you might also be using the Virtuemart ecommerce plugin. I was looking for a way to integrate Google Analytics into Virtuemart so that I could specify a goal and track the number of converted sales.
For the most part you don’t need to worry about doing anything if you just want Google Analytics to measure your traffic in Virtuemart. Slap the code in your main Joomla template and it will work away happily.
If however you want to set a goal to track sales conversions, then you need to provide Google Analytics with a unique URL for the thank-you page in Virtuemart. I found that Virtuemart was simply returning index.php as the thank you page, so had to find a work around to get that unique URL.
Here’s how i did it.
- Create a normal html page called analytics-result.htm
- Into the body of this page, put your analytics code. Make sure you are using the Analytics code for secure sites rather than the standard code if your shopping basket is secure
- Save it in a location accessible through https (if you are using a secure checkout) e.g. https://www.yourdomain.com/analytics-result.htm
- Search for /administrator/components/Virtuemart/html/checkout.thankyou.php
- At the end of the php file, add this code:
<iframe src="analytics-result.htm" width="5" height="5"
frameborder="0" scrolling="no" name="Analytics"></iframe>
- Setup a goal in Analytics and give it your new page as the unique URL: https://www.yourdomain.com/analytics-result.htm
What this method does is to put an Iframe into the thank you page after a customer has ordered. This Iframe contains a standard HTML file with a unique URL that you can setup as a goal page in Analytics. As long as everything is done through SSL your customer hopefully wont get any security errors.
It’s probably far from being the best way to do it, but seems to be working for me.

June 8th, 2007 at 6:25 am
Hi Adam
Thanks for this excellent tip! I was wondering if you were also able to track the e-commerce transaction, as described in Google Analytics page… Basically adding the code:
UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity]
(of course, changing all the [variables] with VirtueMart’s variables)
If you did, can you please post how? Thanks!!!
June 8th, 2007 at 6:26 am
Hi, it’s me again… I guess the entire code got “stripped”.. anyways, here is the link to the page “How Do I Track e-Commerce Transactions?” on Google Analytics, where the instructions (and code) is:
https://www.google.com/support/analytics/bin/answer.py?answer=27203
July 10th, 2007 at 3:57 pm
Thanks Daniel - I missed your comment when I was away on holiday, but that page on Google looks pretty helpful. I haven’t got that deep into it as pushing through the transaction details to the tracking page. Far too complicated for my tired brain to contemplate at the moment. Let us know if you managed to get it working.
July 10th, 2007 at 4:01 pm
It would appear that someone has taken the headaches out of integrating Virtuemart and Analytics if you’re willing to shell out £25 or so for a plugin. See it here: http://www.analytics.fi/
November 6th, 2008 at 4:47 pm
Your solution helped us with Yahoo Analytics! Thank You. Will work for google too, I’m sure. Thanks a million!
November 26th, 2008 at 5:15 pm
can we put it in the VirtueMart Shopping Cart module?