We have recently set up a magento community site running having moved from go.

We are trying to set up the google adwords conversion tracking, there is a piece of code that they want placing on the success page.

Where is this located in


As Step1:

you need to add conversion code on ordee success file


if file no exits then:

copy success.phtml from


and pasted


add your code on new success.phtml

in this file you can order id using below code


OR: check this extension http://www.magentocommerce.com/magento-connect/luka-google-adwords-conversion-tracking.html

  • The line var google_conversion_value = 1.00; in the google conversion code, does that not give all transactions a value of 1? Aug 29 '14 at 15:06
  • 1
    @PeterO'Sullivan Yes it does. You need to replace that with the transaction value. Sep 22 '16 at 21:20
  • GitHub link for Luka extension github.com/lukanetconsult/mage-google-adwords , works perfect.
    – FireBear
    Nov 8 '17 at 23:05

You can copy and paste the following piece of code in your success.phtml


$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getModel('sales/order')->load($orderId);
$total = (float)number_format($order()->getSubtotal(),2);

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 'CONVERSION_ID';
var google_conversion_language = "LANG_CODE";
var google_conversion_format = "FORMAT";
var google_conversion_color = "COLOR";
var google_conversion_label = "LABEL";
if (<?php echo $total?>) {
    var google_conversion_value = <?php echo $total?>;
/* ]]> */
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//www.googleadservices.com/pagead/conversion/CONVERSION_ID/?value=<?php echo $total?>&amp;label=LABEL&amp;guid=ON&amp;script=0"/>

Make sure you change the following variables in the above code -:

  • CONVERSION_ID (e.g. 999999999)
  • LANG_CODE (e.g. en)
  • FORMAT (e.g. 1)
  • COLOR (e.g. #ffffff)
  • LABEL (e.g. -9C8CICMuggQ4O_B1wM)

If you are not confident regarding the above approach then you can use the following module which would easy to configure instead of fiddling around with the code


Hope it helps!

  • 1
    $order in the code above is undefined. Here's a fix: $orderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->load($orderId); $total = (float) number_format($order->getSubtotal(), 2); Jun 1 '15 at 18:23
  • @PartialOrder - Thanks, it has been fixed now in the post above. Jan 29 '18 at 16:22

this is the code which worked for me

//Get Order Number & Order Total
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);


and i got it from this link, maybe it helps someone aswell.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.