Skip to main content

Update: Google Adwords conversion code and Contact Form 7

By November 25, 2016December 6th, 202034 Comments

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.

Additional Settings


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.

Adwords click code

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 editor

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 says:

    Option 2 dows not work. Missing CDATA comments.

    • Mike Martel says:

      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 says:

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

  • Chris says:


    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 says:

    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 says:

      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 says:

    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!!!!

  • 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 says:

      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 says:

    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 says:

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

  • JN says:

    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 (
    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.

    • Katherine says:

      Thank you JN – I am trying option 1 now and it disables the form confirmation so thinking it may already be disables. Mike, would love a solution if you have one. Thanks so much for the clear, concise directions!

    • This is true about the : on_sent_ok and on_submit are deprecated and scheduled to be abolished by the end of 2017. Any update on new format of this post

      Thank you in advance!

  • Jonathan says:

    Thanks very much for this.

    If I put this code into a CF7 form and someone submits the form _without_ going through a Google ad first, will it get counted as a conversion by Adwords?

  • tap says:

    Hi, i have tried option 1, it doesn’t seem to work, Is the implementation the same still? when i check on google tag manager, i am getting an HTTP error msg. HELP

  • Rik says:

    Hi, I have a question. I tried the first option. It doesn’t seem to get counted in Google Analytics. I tested it a few times, no conversion through organic counted.

    So does it count organic too or only through adwords?

  • GP says:


    I had implemented this tutorial with Google Analytics and configured with Google Adwords conversion and working good. But now i have to track conversion from facebook ads too. How can i put facebook event code(Lead) with analytics event in same form?

  • Samuel Gomes Huarachi says:

    Nice MIKE MARTEL. Thanks!!!

  • Great solution I’ve ever found for updating conversion code. Thanks 🙂

  • thank you, very helpfull

  • Mukesh says:

    Explained well, I tried it worked well. Thanks Mike

  • aehageman says:

    Deprecated settings are used.
    Will you update this page with the up to date code.
    you are currently
    number one on yahoo search.

    I use adwords conversions, not analytics.
    Not sure why everyone thinks analytics should be used for conversion tracking and not adwords.
    as they are both important and should be kept separate.
    analytcs is all traffic all conversions
    adwords is just adwords conversions
    neither are 100% so using analytics for both is even less accurate.

  • Yves van Leeuwen says:

    The “on_sent_ok” and its sibling setting “on_submit” are deprecated and scheduled to be abolished by the end of 2017.

  • Ido says:

    Hi, when using the second option I’m getting an error message: “Deprecated settings are used,” The function on_sent_ok: is Deprecated.
    What is te replacement?

  • David says:

    Thanks for the post Michael! One update suggestion. With the new AdWords layout, in Step 3 you need to choose Import now not Website to find Google Analytics goals.

  • Nina Sae Heng says: They post an updated suggested way of event tracking for conversions.

  • Thank you – great guide even for the in-experienced like me!

  • Variable Url is not get in google report section. Below is the modified code and its works well..

    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    var url = window.location.href;
    }, false );