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


The File is success.phtml

and is located at (Can vary if you are using any other theme than default)


Modifying the success-page boils down to copying the PHTML-template template/checkout/success.phtml from the Magento core theme folder app/design/frontend/base/default to your own theming folder app/design/frontend/default/YOURTHEME.

To be sure turn on template hints and view template

To enable template path hints follow the following steps:

  1. Go to Magento admin panel->systems->configuration.
  2. Choose your store view on top left corner in Current Configuration Scope ex: English.
  3. Go to Advanced tab. Under that click on Developer->Debug. ...
  4. hit the place order button to land on order success page.

you can take a hint form below code

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)

Hope it helps!

  • So where I put the conversion code because google says that paste before body close but there is no Body in Magento so where I suppose to paste the code – xr33dx Nov 24 '16 at 12:33
  • added more code , you can paste at very end of the file.Accept answer if it helped you – Vishwas Bhatnagar Nov 24 '16 at 12:38
  • I already try but it not showing page source code – xr33dx Nov 24 '16 at 12:39
  • are you sure that you are pasting on right template file ? – Vishwas Bhatnagar Nov 24 '16 at 12:40
  • yes app/design/frontend/mypackage/mytemplate/template/checkout/success.phtml This is my path – xr33dx Nov 24 '16 at 12:42

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.