• Bondra

    (@bondra)


    Hi!

    I want Google Analytics to track just a form that has been successfully submitted by using:
    on_sent_ok: “_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);”

    then I want to redirect the user to another URL likeso:
    on_sent_ok: “location = ‘http://domain.com/’;”

    Can I add the code in the advanced input field as following?
    on_sent_ok: “_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);”
    on_sent_ok: “location = ‘http://example.com/’;”

    Thanks!

    https://wordpress.org/plugins/contact-form-7/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Bondra

    (@bondra)

    No submission are being tracked by Google Analytis… yet. But I’m not too sure if I can have two rows like the one I mentioned above?

    Hey Bondra! You can try something like this:

    on_sent_ok: "onSentOkFunc();"
    function onSentOkFunc() {
    	_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);
    	window.location = "http://www.yoururl.com";
    }

    You define custom function onSentOkFunc() and call as many functions as you want inside that and call it on send event.

    Can someone verify if this works?

    Actually with one of the latest updates of CF7 it is now possible to set multiple events on send event. Wrapping function is not necessary. Just like this:

    on_sent_ok: "_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"
    on_sent_ok: "location = 'http://example.com/';"

    Dmitry,

    I have 2 submit buttons on the form. Can I have 2 on_sent_ok in the Additional Settings
    example
    on_sent_ok: ” if (document.getElementById(‘chessrating’).value> 2200) {location.replace(‘http://www.greensborochess.org/thank-you-for-your-participation’)} else …….;}”

    on_sent_ok: “location = ‘http://example.com/’;”

    Please advice
    Thanks
    Jacob

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add multiple on_sent_ok?’ is closed to new replies.