WooCommerce AdWords Conversion Tracking

Written By: 

Digital advertising is on uprising with smart tools and technologies. Google Adwords is one of the top tier digital advertising platform used by many businesses online and offline. Many eCommerce websites do advertise their products using this very same platform.  Woocommerce is one of of the widely use Wordpress eCommerce extension which does not have built in conversion tracking tool, so we must have WooCommerce Adwords Conversion code in our instance.

Why we need to track WooCommerce Adword conversion?

Conversion tracking actually helps you to get more conversions in your daily ad budget. Sounds interesting? Yes it does. Conversion tracking is a piece of code which you need to place it at thank you page, with relevant information such as product information and order value.

Setup WooCommerce AdWords Conversion

Following is a small tutorial of WooCommerce Adwords conversion tracking.

  1. Login to your Adwords account and click into Tools and then “Conversions”.
  2. Click on “+ Conversion” to add a new conversion.
  3. Set your conversion name and select the source webpage then save and continue.
  4. Make sure your selection of conversion window is 30 and conversion category is purchase/sale.
  5. Click save and continue.
  6. Then choose “I make changes to the code”, copy the code.
  7. Copy the code below and change the conversion id and conversion label with your id and label.
  8. Paste this code in your theme function.php

function google_conversion_pixel( $order_id ) {
// Lets get order details
$order = new WC_Order( $order_id );
?>
<!– Start Conversion pixel code –>
<script type=”text/javascript”>
/* <![CDATA[ */
var google_conversion_id = YOUR CONVERSION ID;
var google_conversion_language = “en”;
var google_conversion_format = “3”;
var google_conversion_color = “ffffff”;
var google_conversion_label = “CONVERSION LABEL”;
var google_conversion_value = <?php echo $order->get_total(); ?>;
var google_conversion_currency = “USD”;
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/CONVERSIONID/?value=<?php echo $order->get_total(); ?>&amp;currency_code=USD&amp;label=CONVERSION_LABEL&amp;guid=ON&amp;script=0″/>
</div>
</noscript>
<!– End Tracking code –>
<?php
}
add_action( ‘woocommerce_thankyou’, ‘google_conversion_pixel’);
function cdata_markupfix($content) { $content = str_replace(“]]&gt;”, “]]>”, $content); return $content; }
function cdata_template_redirect( $content ) { ob_start(‘cdata_markupfix’); }
add_action(‘template_redirect’,’cdata_template_redirect’,-1);

Still not sure how to do it, please contact us we will help you.