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.