WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Contact Form 7] Run JS after submission for Google AdWords Conversion (13 posts)

  1. mmtomm
    Member
    Posted 2 years ago #

    Hi,

    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(‘http://yourdomain.com/thank-you/’);”
    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>
    <script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/123123123/?value=10&label=qwerqwerqwerqwer&guid=ON&script=0"/>
    </div>
    </noscript>

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

  2. mmtomm
    Member
    Posted 2 years ago #

    no idea for this issue?

  3. lydiamunoz
    Member
    Posted 2 years ago #

    The same problem...

  4. ncompass
    Member
    Posted 2 years ago #

    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.

  5. mmtomm
    Member
    Posted 2 years ago #

    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

  6. ncompass
    Member
    Posted 2 years ago #

    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',
    'http://www.googleadservices.com/pagead/conversion/'+google_conversion_id+'/?value='+google_conversion_value+String.fromCharCode(38)+'label='+google_conversion_label+String.fromCharCode(38)+'guid=ON'+String.fromCharCode(38)+'script=0').appendTo('body');"

    We can replace the three items:

    google_conversion_id
    google_conversion_value
    google_conversion_label

    Can anyone verify that this will work?

  7. ncompass
    Member
    Posted 2 years ago #

    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='http://www.domain.co.uk/folder/file.html' 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.

  8. wp-onliner
    Member
    Posted 2 years ago #

    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!

  9. ncompass
    Member
    Posted 2 years ago #

    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?

  10. aquaclearws
    Member
    Posted 2 years ago #

    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='http://www.mydomain.com/freewateranalysisthankyou' 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!

  11. ncompass
    Member
    Posted 2 years ago #

    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.

  12. mmtomm
    Member
    Posted 2 years ago #

    Hi again,

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

  13. ncompass
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic