10

We have recently set up a magento community site running 1.9.0.1 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 1.9.0.1?

8

As Step1:

you need to add conversion code on ordee success file

app/design/frontend/yourpackage/yourtemplate/template/checkout/success.phtml

if file no exits then:

copy success.phtml from

app/design/frontend/base/default/template/checkout/

and pasted

app/design/frontend/yourpackage/yourtemplate/template/checkout/

add your code on new success.phtml

in this file you can order id using below code

$this->getOrderId()

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

3
  • 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
9

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

/app/design/frontend/yourpackage/yourtemplate/template/checkout/success.phtml

<?php
$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>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<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"/>
</div>
</noscript>

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

http://www.scommerce-mage.co.uk/magento-google-adwords-conversion-tracking.html

Hope it helps!

2
  • 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
1

this is the code which worked for me

<?php
//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.

http://www.jxtgroup.com/how-to-setup-conversion-tracking-in-magento_3912881.html

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.