Update: Google Adwords conversion code and Contact Form 7

Last year I wrote a quick guide to add a Google Adwords Conversion code to Contact Form 7, without redirecting to a ‘Thank You’ page. The method I outlined back then doesn’t work anymore, so high time to write up an updated version!

Option 1: Google Analytics (recommended)

First off: if you are using Google Analytics (which you probably are), then by far the easiest and best way of measuring your conversions is by tracking them in Google Analytics, and link the Analytics Goal to Adwords. That way you also have better data in Google Analytics!

The below steps assume you already have Google Analytics installed, using the Universal Analytics snippet and that your Adwords and Google Analytics account are already linked!

1. Edit your Contact Form 7, and go to the Additional Settings tab.

2. Add the following line:

on_sent_ok: "ga('send', 'event', 'Contact Form', 'submit');"

And save the form.



3. Log into Google Analytics, and navigate to your property > Admin > View > Goals, and click the “+ New Goal” button

Create a Goal

4. Select the “Contact us” template

GA Goal Template

5. Select “Event” as the trigger:

GA Goal

6. Set the Event Category to “Contact Form” and the action to “submit”

CF Event details

7. Save the Goal and move on to Adwords! In Adwords go to Tools > Conversions in the main menu

Tools > Conversions

8. In the sidebar, select “Google Analytics”. You should see the Goal you just created select it and press import to continue.
If you do not see your Goal yet – refresh the page in 5 minutes or so. This step sometimes takes some time.

GA Goal in Adwords

9. Set the final settings for your conversion to finish!

That’s it! Make a form submission and check Google Tag Assistant to see if its working, and check this guide to make sure your conversions are coming through to Adwords.

Option 2: Google Adwords Conversion code

If you really need to get the Google Adwords Conversion code to be triggered by Contact Form 7, this is how to do it:

1. In your Adwords console, go to Tools > Conversions in the main menu

Tools > Conversions

2. Create a new conversion (or edit an existing one, if you did this already!)

New conversion

3. Select ‘Website’ conversion and give it a name and set the options

4. Go to the next step and scroll down to “Install your tag”. There, pick the “Click” option and copy the code that appears.


5. Edit the CF7 form you want to track conversions for and paste the code from the previous step at the end of your form

Contact Form 7

6. Finally, go to the “Additional Settings” and add the following line:

on_sent_ok: "typeof goog_report_conversion === 'function' && goog_report_conversion();"

(If you are already tracking Google Analytics through these settings, you can use the line below. However, you should really use option 1 above!)

on_sent_ok: "typeof ga === 'function' && ga('send', 'event', 'Contact Form', 'submit'); typeof goog_report_conversion === 'function' && goog_report_conversion();"

Additional Settings

That’s it! Make a form submission and check Google Tag Assistant to see if its working, and check this guide to make sure your conversions are coming through to Adwords.

  • Marxxx
    Posted at 09:03h, 07 December Reply

    Option 2 dows not work. Missing CDATA comments.

    • Mike Martel
      Posted at 17:01h, 09 December Reply

      Hi Marxxx – it’s true that due to the way WordPress formats the code, the CDATA comments become invalid. Google Tag Assistant will notify you of this. However, this shouldn’t prevent the AdWords code from working.

      Have you tested it and seen that it didn’t register the conversion?

  • Dave
    Posted at 16:29h, 17 December Reply

    Best solution I’ve found online for this. Thanks.

  • Chris
    Posted at 21:44h, 11 January Reply


    I tried option 2. The conversion gets tracked in Adwords without the Analytics Tracking.
    But the impression of the form gets tracked, not click of the submit button. What am I doing wrong?
    Do I have to alter the tag or add something?
    Thanks for helping me out!

  • Christian
    Posted at 05:25h, 13 January Reply

    Hello Mike,

    don’t know if my comment / question got through. I’m trying once again:

    Option 2 does work, It counts the conversion in adwords.
    But it simply counts the impression of the page with the form instead of the actual submit. What am I doing wrong? Do I need to alter the code below the submit button after copying from the adwords account?

    Thanks in advance!

    • Mike Martel
      Posted at 11:22h, 13 January Reply

      Hi Christian, that is strange – the code you paste under the contact form doesn’t get triggered unless goog_report_conversion() is called, which happens only when the form is submitted. Have you checked with Google Tag Assistant when the tag is triggered?

      Feel free to send me the link to the page through my contact form, I can have a look to see if the code is inserted correctly.

  • Tuan
    Posted at 21:49h, 22 February Reply

    You’ve save my day!!!
    This is the best solution for contact form 7 to work with Google adwords conversion tracking code.
    Thanks you so much!!!!

    • Tuan
      Posted at 03:38h, 24 February Reply

      I have a small question, on google i recived 3 conversion, but i only get 1 email form the CF7, IDK what’s wrong. 🙁 but it could effect the CPA cost.

      • Mike Martel
        Posted at 12:37h, 24 February Reply

        Hi Tuan, have a look at what Google Tag Assistant shows when you visit the page with the contact form, and when you submit it.

        • Tuan
          Posted at 05:34h, 26 February Reply

          Thanks Mike, I’m checking on it 🙂

  • Tomas Svitorka
    Posted at 11:29h, 17 March Reply

    Hi, what is the “label” value in the google tracking code? Thanks a lot. For some reason option 1 doesn’t work for me 🙁

    • Mike Martel
      Posted at 17:43h, 17 March Reply

      Hi Tomas! When you create a conversion in Adwords it is automatically assigned a conversion label. So you can leave that as is in the tracking code you get from Google Adwords.


  • Nio
    Posted at 13:02h, 24 April Reply

    Hi Mike,

    While searching in google for solution on how to Google Adwords code on contact form 7, I found this solution : does it work with new version of CF7 (2017)? as this post year old 2016!

    OR if you have any other solution I really need help on that!

    your earliest reply would be appreciate.

    Thanks a lot.

    – Nio

    • Mike Martel
      Posted at 17:52h, 24 April Reply

      Hi Nio, this solution is from November, so only 5 months old! As far as I know, everything still works as is.

  • JN
    Posted at 17:14h, 27 April Reply

    Mike, according with the CF7 website the on_sent_ok will be removed later this year.

    Here is the link and the note from CF7 website (https://contactform7.com/additional-settings/#javascript)
    Note: on_sent_ok and on_submit are deprecated and scheduled to be abolished by the end of 2017. You can use DOM events instead of these settings.

    How can the code be modified to make sure it keep working in the future?

    Thank you.

Post A Comment