How to Implement A/B Testing with WordPress and Headway

When using Google Analytics – or any service – to implement A/B testing on your website, they ask you to paste a few code snippets on an individual page – and on that page only. Not only that, but they want the code in a specific place – right before the closing body tag, in the head tag – depends on the snippet. There are often a few different ones, too.

This is a pain in the butt on WordPress. Luckily for you, I’ve done most of the work for you! This is actually a useful bit of code for any site running WordPress – this isn’t Headway specific. We’re hooking into the standard WordPress filter hooks for wp_head and wp_footer here.

As with any of our tutorials that involve adding PHP code to your website, make sure you have FTP access and you know how to get to your custom_functions.php folder. An error could cause your site to go down. If that happens, you’ll need to remove the code from custom_functions.php manually by editing the file and saving it back to the server via FTP. Double check your syntax – you don’t need to add another opening PHP tag if there is an opening tag that hasn’t yet been closed – i.e. an extra {code type=PHP}

Use this code – modified to include the necessary tracking code for your split test & the correct page IDs – when you have to add code to the header of a specific WordPress page:

{code type=PHP}


SCRIPT GOES HERE!


{/code}

Use this code – again, modified – when you have to add code to the footer of a specific page.
{code type=PHP}


SCRIPT GOES HERE!


{/code}

Spread the word!

One Response

Leave a reply

Copyright © 2016 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress