Tracking Facebook Leads with WordPress Contact Form 7

By December 16, 2015Facebook

The Contact Form 7 plugin for WordPress is a very popular WordPress plugin – I reckon I see it on 70% of websites. It’s an excellent free plugin for creating contact forms, however, I have one gripe with it: by default, it does not redirect to a different thanks you page when a visitor submits a form.

By default, when a visitor to your website submits a contact form, they see a little message appear just below the contact form like this:

Contact form 7 success message

Sure, this might be a nice user experience – not loading another “thank you” page, but for us analytics and tracking guys, it’s a pain in the bum. Why? Because it makes it tricky to track leads – it’s much easier to setup conversion tracking when you send someone to a different URL after they’ve submitted a form.

Being the fanatical Facebook Ads person that you are, I’m pretty sure you want to be able to track conversions form lead generation forms like Contact Form 7. Then you can glance at your Facebook ads reports and see what it’s costing you per lead.

Here are two options for setting up lead tracking on websites using the Contact Form 7 plugin for WordPress.

Option 1: Redirect to a thank you page

Add the following piece of code to the Additional Setting field settings of your form:

on_sent_ok: "location.replace('http://www.YOURSITE.com/thank-you');"

It should then look like this:

Contact Form 7 Additional settings for redirect.

You will then need to setup a /thank-you page where the visitor will be redirected after submitting the form.

Then from within Facebook Ads Manager, you can go to your Pixels settings and Create Conversion and add the Thank You page URL into the form as follows:

Facebook Conversion Pixel - create conversion.

Using this method also means you can easily setup retargeting, not to mention Google Analytics Goal tracking, conversion tracking for Twitter and other ad platform tracking. This is your ideal setup as it makes it easy to track conversion in multiple platforms.

Lazy marketers, you might prefer option 2.

Option 2: Trigger a Facebook conversion on the form page

If you don’t want to go to the hassle of adding a new “Thanks You” landing page, then there is another option. And that is to trigger a specific Facebook conversion type, such as a lead.

Using the following code in the Additional Settings field, you can trigger a Lead Facebook conversion event.

on_sent_ok: “fbq(‘track’, ‘Lead’);”

So it should look like this in your form settings:

Triggering a Facebook Lead events in Contact Form 7

You could use this method to trigger any of the Facebook standard conversion events.