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.

additional-settings-ga

 

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

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.

29 Comments
  • 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

    Hello,

    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.

      Mike

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

    • Katherine
      Posted at 02:23h, 30 April Reply

      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!

    • Devereaux Harry-Barnwell
      Posted at 01:49h, 24 May Reply

      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
    Posted at 07:21h, 06 May Reply

    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
    Posted at 08:39h, 10 May Reply

    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
    Posted at 03:13h, 11 May Reply

    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
    Posted at 00:15h, 24 May Reply

    Hi

    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
    Posted at 02:40h, 25 May Reply

    Nice MIKE MARTEL. Thanks!!!

  • Whitehat Agency
    Posted at 17:47h, 05 June Reply

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

  • Akash Talele
    Posted at 01:07h, 16 July Reply

    thank you, very helpfull

  • Mukesh
    Posted at 20:48h, 10 August Reply

    Explained well, I tried it worked well. Thanks Mike

  • aehageman
    Posted at 10:59h, 08 November Reply

    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
    Posted at 22:38h, 21 November Reply

    The “on_sent_ok” and its sibling setting “on_submit” are deprecated and scheduled to be abolished by the end of 2017. https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/

  • Ido
    Posted at 19:55h, 15 December Reply

    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
    Posted at 01:15h, 16 December Reply

    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.

Post A Comment