Support » Plugin: WP-Matomo Integration (WP-Piwik) » Problem with on_sent_ok in Contact Form 7

  • Resolved maidstein



    Since some days I have a problem with my formular tracking using Contact Form 7. CF7 tells me that “on_sent_ok” is deprecated and that I have to replace it with DOM Events. I have no idea – does anybody have?

    Here is the link to the helping page of Contact Form 7:

    Thanks in advance!


    • This topic was modified 4 years, 2 months ago by maidstein.

    The page I need help with: [log in to see the link]

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


    Hello Breakling!

    Maybe I have to clarify the problem. “on_sent_ok” is used to assign a JavaScript code that will be executed when a form submission completes and mail has been sent successfully. I use this small code line to track these user actions as Goals:

    on_sent_ok: “_paq.push([‘trackGoal’, 24]);”

    For the future Contact Form 7 recommends DOM Events. But I have to admit that I get off at this point.

    Please let me know if you feel responsible or not.



    Plugin Author braekling


    Hi @maidstein,

    WP-Piwik only creates a connection between Piwik and your WordPress page including getting the JavaScript code from Piwik and posting it to your page, if enabled.

    But WP-Piwik is not involved in the tracking itself, and because I’m not using events on my personal sites, I can’t really help you with this issue.

    Best, you should as the Piwik community ( or the Contact Form support.

    Just one idea, but not tested: If you take the code shown on the CF7 support page, and you just replace the Google Analytics call by the Piwik call, shouldn’t that work?

    In functions.php:

    add_action( 'wp_footer', 'mycustom_wp_footer' );
    function mycustom_wp_footer() {
    <script type="text/javascript">
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        _paq.push([‘trackGoal’, 24]);
    }, false );
    • This reply was modified 4 years, 2 months ago by braekling.
    Thread Starter maidstein


    Hi Breakling!

    I have not tried your idea ’cause as I believe this is a global solution for all sites. But I need different code for different forms. Unfortunately I do not dare too much to solve the problem in this way. Sorry!

    So I decided to search furthermore for another solution and found a plugin for Contact Form 7 called Contact Form 7 Redirection. Here you can add individual JS-Code as in my case:

    _paq.push([‘trackGoal’, 24]);

    The number ’24’ is variable from form to form.

    That’s it!

    However, thanks for helping me!


    • This reply was modified 4 years, 1 month ago by maidstein.
    Plugin Author braekling


    Thx for your feedback! Hope this will also help some other users. 🙂

    I tested it and I can confirm its working. Remember if you want to track multiple goals, you have to choose a unique value for 'mycustom_wp_footer' for each goal.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with on_sent_ok in Contact Form 7’ is closed to new replies.