Adding Google Adwords Conversion Tracking To Genesis Theme

Any time you set up a Google Adwords campaign you’ll naturally want to track how effectively you are spending your money.  There are several ways to track conversion, using the variety of conversion tracking options within Adwords, or importing conversions from within Google Analytics.

Each method has advantages, however here is one way to implement the Conversion Tracking code if you are using a Genesis theme.  Obviously it goes without saying that you’re editing a Child or Custom theme and not the core Genesis Framework.

Google’s instructions for adding conversion tracking are very straightforward, but understandably they do not give detailed instruction on how to deploy the tracking on individual sites.

The code from your Adwords Conversion tracking will look something like this:

image of code snippet

And the instructions state that you need to place the code immediately after the opening <body> of your page.

Using Genesis Hooks to add conversion code

Genesis provides lots of useful hooks to allow us to add bits and pieces to our websites.  The Hook we’re interested in here is:


and so having identified the Hook we have to think about what we are going to insert.  As I see it there are two options.  One is to insert the tracking code directly, and the other would be to include a file.  Either way we create a custom function to pull in the code.  Like this:

add_action('genesis_before', 'include_tracking');

The conversion code should only be placed on the pages that count as a conversion.  So we need a conditional statement to say that the code should only be inserted on the relevant pages.  Most likely a “thank you” page.

I opt to use an “include” and place the conversion code in a separate file.  The only reason for this is that as this code is going into the function.php file I want to try and keep the amount of code in there to a minimum.  There could be very good reasons for doing things differently.

So we end up with something like this:

//* Add Tracking Code for Conversions
add_action('genesis_before', 'include_tracking');

	function include_tracking() {
		if ( is_page( '3380' )) {

Remember.  This needs to go into the functions.php file in a child theme of a Genesis powered WordPress site.  It’s not going to work anywhere else!

Published on May 23, 2016

About Chris

Other articles you may like