Cookie Consent by Free Privacy Policy Generator Update cookies preferences

Using The Shopping Cart Total In Magento As The Conversion Value In Adwords

When setting up conversion tracking in Google Adwords, one of the options you will need to select is how much each conversion is worth to your business.

If you selling a variety of goods all with different values, it’s impossible to place a specific value for each conversion as they will always be different.

Fortunately, in Magento, it’s easy to set the actual total of each order as the conversion value.

Conversion value setup on Adwords conversion tracking

During the conversion tracking setup in Adwords, you have three options to choose from; conversion action has the same value, conversion value may vary and conversion has no value.

When you select ‘the value of the conversion may vary’, you will be asked to assign a default value. Leave this as 1 because we will be changing it in a few minutes.

Once you have completed the rest of the setup, Google will provide you with some pre-populated code to add to the success page in your Magento theme. It will look like this:

<!-- Google Code for test Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */ 
    var google_conversion_id = xxxxxxxxxx; 
    var google_conversion_language = "en"; 
    var google_conversion_format = "3"; 
    var google_conversion_color = "ffffff"; 
    var google_conversion_label = "xxxxxxxxxxxxxxxxxxxx";
    var google_conversion_value = 1.00; 
    var google_conversion_currency = "GBP"; 
    var google_remarketing_only = false; /* ]]> */
</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/1041489413/?value=1.00&amp;currency_code=GBP&amp;label=9rNtCPXapV0QhbzP8AM&amp;guid=ON&amp;script=0"/>
</div>
  
</noscript>


However, as you can see, they have used the default value we entered previously for the conversion value.

To change this to use the total of the shopping cart (minus shipping), we need to do two things.

First, we need to add the following to the top of the success page:

<?php 
    $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId()); 
?>

Secondly, under this snippet of code you have just added, paste the code provided by Google and replace the ‘1.00’ at the end of google_conversion_value with the following:

<?php 
    echo number_format( $order->getGrandTotal(), 2 ) 
?>

Check that everything is working as it should within Google Tag Manager and then you can start getting an accurate ROI for your Adwords account.

If you enjoyed this article, read the other Blog articles from our Magento agency or browse the site to see what else we do with Adobe Commerce, PunchOut Catalog and more.

Get in touch for help with your latest Magento or eCommerce project.


...
Luke

share:

Ready to start your next project?

See how we can help you accelerate your business