Google Adwords and Magento – Conversion tracking

So you started an Adwords campaign and would like to measure leads and conversions via Adwords. That’s possible of course! First, go to Adwords and to Conversions. Create a conversion and copy the code. It will look something like this:

<!– Google Code for Bestelling Conversion Page –>
<script type=”text/javascript”>
/* <![CDATA[ */
var google_conversion_id = XXXXX;
var google_conversion_language = “en”;
var google_conversion_format = “3”;
var google_conversion_color = “ffffff”;
var google_conversion_label = “YYYYY”;
var google_conversion_value = 0;
/* ]]> */
<script type=”text/javascript” src=””>
<div style=”display:inline;”>
<img height=”1″ width=”1″ style=”border-style:none;” alt=”” src=””/>

Go to the file /app/design/frontend/default/default/template/checkout/success.phtml and add at the bottom of the file:

$order_details = Mage::getModel(‘sales/order’)->loadByIncrementId(Mage::getSingleton(‘checkout/session’)->getLastRealOrderId());
$adwords_saleamt = $order_details->subtotal;

Copy your Google Adwords code as well under this code. Under var google_conversion_value = 0; create a line and add:

if (<?php echo $adwords_saleamt; ?>) {
google_conversion_value = <?php echo $adwords_saleamt; ?>;

Source: With thanks to: