WordPress Contact Form 7 – Tracking Form Submissions in Universal Analytics

Published 9 Comments on WordPress Contact Form 7 – Tracking Form Submissions in Universal Analytics

Are your Contact Form 7 submissions not working fine? Is the ‘Thank You’ success message flashing for a second and disappearing? The problem might be in the on_sent_ok hook.

The standard recommendation on the Contact Form 7 website is to use the following code.
on_sent_ok: “_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);”
The above code will work fine with Google’s Classic Analytics. For the new Universal Analytics code you need to change the JavaScript call to the following:
on_sent_ok: “ga(‘send’, ‘event’, ‘Contact Form’, ‘Submit’);”
Now, if you are using Yoast’s WordPress Google Analytics plugin, you will have to change the trigger to the following:
on_sent_ok: “__gaTracker(‘send’, ‘event’, ‘Contact Form’, ‘Submit’);”
I do not know why, but Yoast has decided to use ‘__gaTracker’ instead of ‘ga’.


  1. Thanks Kathir for the clear explanation and mention about Yoast GA plugin. I found about this on another website, but you made it very clear here. (Using ga instead of __gaTracker shows “not defined” error in the console).

  2. Hi, and thanks for the post.

    I have an issue with this tracking code.
    1.Is yoast seo plugin the same as yoast GA?

    2.I have seen this code on other pages as well, but they use ‘sent’ instead of ‘Submit’

    Whats the diffrence?

    1. Yoast SEO and GA are from the same people, but this code is specifically for the GA plugin. Where in Yoast SEO do you see tracking codes? Maybe I haven’t tried their advanced functionality yet.

  3. I’ve been working on this all afternoon. We have a WP site with Yoast and Contact Form 7. Other posts had “send” instead of “Submit” for the last part of the code. Your code for Yoast+Contact Form 7 worked great. Thanks Kathir!

  4. It seems Yoast plugin has been replaced with Google Analytics by MonsterInsights. I can’t find any code working for it… which one should?

Comments are closed.