Author Topic: How to add Google adwords to virtuemart  (Read 7450 times)


  • Beginner
  • *
  • Posts: 7
How to add Google adwords to virtuemart
« on: May 14, 2012, 16:56:45 pm »

I have spent the last 2 days trying everything in this forum as to how to add Google adwords tracking code to virtuemart and none of the stated suggestions work.  Any suggestions on other sites searched are just so called solutions copied from this forum.

What I Require
I have a google adwords campaign and I simply want to track each purchase made within my virtuemart store.

What I have done so far
When creating the google adwords code you have the following setting to choose from before your code is generated.
Conversion category - My Sales
Page security level   - can be HTTP or HTTPS (I have selected https as my checkout uses https)
Markup Language - can be XHTML or html (I have selected xhtml as its being added to the following script checkout.thankyou.tpl.php
Conversion value - a value for your conversion (I used 15)

I have the code added to the bottom of the public_html/components/com_virtuemart/themes/default/templates/pages/checkout.thankyou.tpl.php
The code is not verified by google adwords and conversion are not showing up.

I have done a test with another conversion (I added a adwords conversion tracking code to my sites index.php and this is being picked up)

Please see attached images.

1: What is the correct file to put the conversion code in as it is not checkout.thankyou.tpl.php

2: What is the difference between
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id") and

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.thankyou&order_id=".$db->f("order_id")

Any tried and working solution much appreciated

Tom.  :)

[attachment cleanup by admin]


  • Contributing Developer
  • Full Member
  • *
  • Posts: 872
    • Squangle ltd
Re: How to add Google adwords to virtuemart
« Reply #1 on: May 15, 2012, 00:00:09 am »
Have a look at a post from me, I go to this to work after giving a lot of thought!
614869 products in 747 categories with 15749 products in 1 category.
                                             Document Complete   Fully Loaded
                Load Time First Byte Start Render   Time      Requests      Time      Requests
First View     2.470s     0.635s     1.276s          2.470s       31            2.470s      31
Repeat View  1.064s     0.561s     1.100s          1.064s       4             1.221s       4


  • Beginner
  • *
  • Posts: 45
Re: How to add Google adwords to virtuemart
« Reply #2 on: June 02, 2012, 17:45:00 pm »
Have a look at a post from me, I go to this to work after giving a lot of thought!

Do you have a link to that post stinga ?  I just did a search and it didn't show up under your name so I must be searching for the wrong term.


  • Beginner
  • *
  • Posts: 45
Re: How to add Google adwords to virtuemart
« Reply #3 on: June 12, 2012, 17:54:16 pm »
Probably more a case of by default VM forum doesn't notify user of replies to threads so it just kills the forum with lots of posts and people not coming back to that thread to check on it.  Makes far more sense to notify by default even if it's a daily / weekly notification and allow users to disable it than the other way around if you ask me.

In the end we scrapped using add words because there was a lot of competition and Google was eating thousands of dollars a month and returning very little in the way of sales.

If you want to track your conversions,  I created an override for the default.php in pluginresponse adding the google code for sale conversion to the end of it.

If you are unsure how to make an overrride, just create a directory in your template directory  that is html/com_virtuemart/pluginresponse and copy the default.php from the plugin response directory in your virtuemart directory.  then just add your google conversion tracking code (this is not the standard analytics code) to the bottom of the newly copied deafult.php

Then what happens is when payment is made and the order confirmation page is displayed after a payPal payment is confirmed, the page shown has the tracking conversion code at the bottom of it, this page doesn't display unless payment is confirmed by PayPal otherwise it goes back to cart and the page is not shown.  Worked for the short time we still had google ads running.

Doing it that way it will not be overwritten when you do a virtuemart update :)

Hope that helps!

If you need a hand feel free to give me a shout and I'll help where I can :)


I just spotted this is the VM1 forum and I'm using VM2 so you can’t do the override in the way I did I'm afraid.  It;s a similar process though :)


  • Beginner
  • *
  • Posts: 7
Re: How to add Google adwords to virtuemart
« Reply #4 on: June 16, 2012, 15:00:45 pm »
Hello Celtic Web,

Thanks very much for your informative suggestions on how to achieve what I requested.  I will try it.

Thanks again.


  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3510
  • VirtueMart Version: 3.8.9
Re: How to add Google adwords to virtuemart
« Reply #5 on: June 22, 2012, 16:53:25 pm »
Put the tracking adwords code into the administration/components/virtuemart/html


Just after this code

Code: [Select]
if( !isset( $_REQUEST["order_id"] ) || empty( $_REQUEST["order_id"] )) {
else {
include( CLASSPATH. "payment/ps_paypal.cfg.php" );
$order_id = intval( vmGet( $_REQUEST, "order_id" ));

$q = "SELECT order_status FROM #__{vm}_orders WHERE ";
$q .= "#__{vm}_orders.user_id= " . $auth["user_id"] . " ";
$q .= "AND #__{vm}_orders.order_id= $order_id ";
if ($db->next_record()) {
$order_status = $db->f("order_status");
if($order_status == PAYPAL_VERIFIED_STATUS
      || $order_status == PAYPAL_PENDING_STATUS) {  ?>
        <img src="<?php echo VM_THEMEURL ?>images/button_ok.png" align="middle" alt="<?php echo $VM_LANG->_('VM_CHECKOUT_SUCCESS'); ?>" border="0" />
        <h2><?php echo $VM_LANG->_('PHPSHOP_PAYPAL_THANKYOU'?></h2>

[i][b] <!-- Google Code for Web Site Sale Conversion Page -->[/b][/i]


Joomla 3.9.27
php 7.4