Support » Plugins » [Plugin: Contact Form 7] Run JS after submission for Google AdWords Conversion

  • mmtomm



    I have seen this additional Settings Box in my form but do not understand, how I can run complex JavaScript after submission.
    I don’t want to use a “Thank you Page” if not necessary.
    there is this example I found:
    on_sent_ok: “location.replace(‘’);”
    How can I use on_sent_ok: when I have some Script to run which is large like this:

    <!-- Google Code for ContactFormSubmitted Conversion Page -->
    <script type="text/javascript">
    /* <![CDATA[ */
    var google_conversion_id = 123123123;
    var google_conversion_language = "de";
    var google_conversion_format = "1";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "dsfgfsdfgsdfgsdfg";
    var google_conversion_value = 0;
    if (10) {
      google_conversion_value = 10;
    /* ]]> */
    <script type="text/javascript" src="">
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src=""/>

    The purpose is, to place ads with google adwords and implement an conversion tracking with the target “contact form submitted”
    Thanks for help

Viewing 12 replies - 1 through 12 (of 12 total)
  • no idea for this issue?

    The same problem…

    Just put in it to the “# Sender’s message was sent successfully” field… I’m testing, but I do not see why this would not work.

    Just put in it to the “# Sender’s message was sent successfully” field… I’m testing, but I do not see why this would not work.

    Hi ncompass,
    this does not work!
    although it does not crash the page the google conversion tracking still tells “unverified”, the status it tells until a successfull conversion has take place

    Ok – after hunting around a bit more, this was a bit of a long shot and I know I’ve had conversions and they are not being recorded, so here goes attempt two. (my aim is not to have to create a Thank you page):

    on_sent_ok: “jQuery(String.fromCharCode(60)+’img/’+String.fromCharCode(62)).attr(‘height’,’1′).attr(‘width’,’1′).css(‘border-style’,’none’).attr(‘src’,

    We can replace the three items:


    Can anyone verify that this will work?

    That failed – sorry… This is my newest attempt

    OKay back to basics… here is what I did to make Google Adwords Conversion Code work and track properly.

    Step 1) I created a new HTML file it only contained the Tracking code inside some html tags

    <html>full Adwords Conversion code here</html>

    Step 2) In the Senders Success Message box I added

    <iframe src='' width='1' height='1' frameborder='no'></iframe>

    Thus when the AJAX form called the hidden div it will also also call the iFrame and therefore the Tracking Code.

    I really hope that this time I will have got this right comments welcome.

    Hi ncompass,

    you are the master of my day!!! Thank you very much for this little trick!!! Even though, that I didn’t have to insert such a large Google AdWords Conversion script, your trick helped me a lot. I had to track my form with a normal google analytics tracking code snippet. But the normal alternative to put it in the additional Settings box didn’t work. The flashbox appears but the js code after this in the additional Settings box did’n run. Instead of long debugging sessions I tried your suggestion and it works well!

    Thank you for this!

    If you add the normal GA code to the iFrame file it will serve as a check as well… as your Conversions in Adwords should match the Analytics for that file.

    Does that make sense?

    so the new HTML page you made is a thank you page?

    I already had a Page (Free Water Analysis) with my form on it ([contact-form 4 “Free Water Analysis”]). Then I made another Page (Free Water Analysis Thank You) with only a brief “Thank you for your request. We’ll get back to you soon” text and the Google Adwords conversion tracking code in the body.

    So to make this work I should leave the Additional Settings section of my form blank. And in the Messages section of the form, for ‘Sender’s message was sent successfully’, I should only put <iframe src=’’ width=’1′ height=’1′ frameborder=’no’></iframe> ?

    Or does that code actually open my thank you page in an ‘invisible’ window, so I should still put some text in the Sent Successfully box? Such as: “Your message was sent successfully. Thanks. <iframe>(stuff)</iframe> “

    This will be amazing if I can get it to work. Thank you for your help so far!

    Yes that should work I don’t see why not… but I made a very basic HTML file with ONLY the Adwords Conversion code and Standard Analytics code in it and then uploaded via FTP.

    In other words my ‘thankyou’ page was not actually part of WordPress. But I don’t see why you cannot reference a WordPress page in the iFrame – that should work.

    Hi again,

    I did it as described, but my conversion tracking still tells: unverified – no recent conversions 🙁

    I can confirm that when using a simple HTML file containing just the conversion codes needed then it works fine… I have not tested what happens if you add the conversion code to a WordPress Page and use that.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Contact Form 7] Run JS after submission for Google AdWords Conversion’ is closed to new replies.