In this article I will explain and provide an example on how to Add Google conversion code to Woocommerce to capture online sale conversions and values from the ‘order received / thank you’ page.

There are many plugins that you can get for free or either purchase, I tried them all and none of them gave me the correct solution according to the Google website. Each plugin had some form of issue whether it was placement of the code, incorrect order total being pulled through or not at all.

It is pretty straight forward so I am simply just going to show you the entire code you need to copy, paste and edit a couple of things. The only changes you need to make are the ID, LABEL and CURRENCY see the comments in the code for the only areas you need to change.

Once you have made the above changes to the code below to match your conversion details simply paste this code into your functions.php

You may have noticed the ‘noptimize’ comments I have in my code, this is because on our websites we run the Autoptimize WordPress plugin and those comments wrapped around the script prevents that script from being minified (minifying the code removed important data that Google requires).

The code also puts the script in the correct place according to Googles guidelines that’s why we are hooking into the wp_footer and not the woocommerce_thankyou is that all the other plugins and scripts including the Woocommerce tracking code guidelines add the action to this hook which puts the code somewhere up in the middle of the page.

I hope these instructions are pretty straight forward and easy to follow, if you have any comments or questions please jump on our Facebook page where we can answer any questions you may have.

Happy coding.