Magento - AdWords Conversion Tracking

When you use Google AdWords to receive more traffic, don’t forget to track the traffic. AdWords Conversion Tracking is a free tool to help you understand how many users actually buy products or services from you.

Installing AdWords conversion tracking codes is pretty straightforward.

Open the file /app/design/frontend/your_interface/your_theme/template/checkout/success.phtml.

Find the following code in the file.
<?php echo $this->__(’Your order # is: %s’, $this->getViewOrderUrl(), $this->getOrderId()) ?>.
<?php else :?>
<?php echo $this->__(’Your order # is: %s’, $this->getOrderId()) ?>.
<?php endif;?>

Add the following code under the above code. If your success.phtml is customized, add it at the end of the file. In most cases, it should work.

<?php
//-------------------------------------------
// ADWORDS CONVERSION TRACKING
//-------------------------------------------
$order_details = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$adwords_saleamt = $order_details->subtotal;
?>
<!-- Google Code for Purchase/Sale Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = ---YOUR_GOOGLE_CONVERSION_ID---;
var google_conversion_language = "en";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "purchase";
var google_conversion_value = "<?php echo $adwords_saleamt; ?>";
//-->
</script>
<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/---YOUR_GOOGLE_CONVERSION_ID---/?label=purchase&guid=ON&script=0"/>
</noscript>

To look at the conversion data from Google AdWords, generate reports as follows:

Reports -> Create Report -> … ->
Add or Remove Columns from Advanced Settings (Optional) -> Choose conversion related columns.

AdWords Conversion Report

This code is to track conversion rate for regular sales.

2 Comments

  • By rocky, June 22, 2009 @ 4:13 am

    this is a nice post

  • By Joe Fletcher, August 30, 2009 @ 9:54 pm

    Worked like a charm! Thanks for the concise tutorial. I edited in the php for the order subtotal into the noscript part as well, although it’s probably not necessary since Magento requires javascript.

Leave a comment