Friday, November 18, 2011

Tracking adwords conversions on a WordPress site

Knowing how many people have clicked your Adwords ad and then gone through your site and contacted you via a form is critical - it shows how much value you're getting from your ad.

Here's one way:

1) Paste your Adwords conversion code into a html document (for example, contactconversion.html), and save it in your live site's theme's folder.

2) Edit the footer.php and add this code at the end (before closing tag :



if (is_page('thanks'))
{ include ("contactconversion.html"); }
elseif (is_page('otherthankspages'))
{ include ("conversion_other.html"); }
?>

I've left an elseif in in case I want to implement tracking on one of our other forms)

See this post for additional information.

3) Now I need to create a thanks page in Wordpress. Just make it private so it doesn't show in any menu. The is_page value should of course match the page.

4) I use Contact Form 7, and so I use the Additional Settings field of my form to specify what happens after the form is submitted:

on_sent_ok: "location = 'http://www.mydomain.com/thanks';"

As mentioned above, the end of the URL will match the is_page value.

See this page for further details.

And voilĂ , a form submission will redirect to the new thanks page and put in the code in contactconversion.html and my Adwords conversions will be tracked!


No comments: