Ready to get started?Download WordPress


Contact Form 7
Contact form 7 and google analytics problem (9 posts)

  1. sallemannen
    Posted 2 months ago #


    I've spent couple of hours trying to solve this without any results.
    My problem is how i track for example submitted contact forms on my google analytics. I've tried different codes in contact form, these are:

    on_sent_ok: "ga('send', 'event', 'Contact Form', 'sent');"
    on_sent_ok: "_gaq.push(['_trackEvent', 'Intresseanmälan1', 'Submit']);"
    on_sent_ok: "ga('send', 'event', 'Intresseanmälan2', 'sent');"
    on_sent_ok: "ga('Submit', 'event', 'Intresseanmälan3', 'sent');"
    onClick="_gaq.push(['_trackEvent', 'Intresseanmälan4', 'Skickat', 'Kontaktformulär',, false]);"
    on_sent_ok: "ga(['_trackEvent', 'Intresseanmälan5', 'Skickat', 'Kontaktformulär',, false]);"

    and no one works. When i add the code in additional settings and then submitt a form name, email and so on doesnt reset (the form goes through). This can be fixed by removing the code in additional settings.

    So i appreciate some help here..


  2. pcreytens
    Posted 2 months ago #

    Same problem here:
    on_sent_ok: "ga('send', 'event', 'Contact Form Content Page', 'Verzenden');"

    Followed instructions from here:

    And (re-) started plugin several times...

  3. mpek
    Posted 2 months ago #

    Did you enter the code in "additional settings" below your form and email form(s)?
    Check here:

    I'm trying this feature as well. No additional help from me at this point...sorry

  4. RayBoyd1455
    Posted 2 months ago #

    Also have a issue with the Analytics code. With the code in the Additional Setting box the code works but the form is not displaying the "Thank You" message so we are getting multiple submissions from the same user.
    I was using this code;
    on_sent_ok: "_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"
    We have multiple forms so I was changing the 'Contact Form' string for each form, this would create a unique Category in Google Analytics for each form.
    Here is one of the forms;

  5. Roundcape
    Posted 2 months ago #

    Hi All,

    I was struggling with this, and other posts didn't seem to resolve.

    Additionally, errors were very random, some of my sites work, some don't. I was getting a "Uncaught ReferenceError: _gaq is not defined" when submitting (you can see this by opening the developer tools, console on google chrome)

    At the end I resolved by introducing the following code (Ref 1) on the Header, at the beginning, of the page where your contact form is, replacing the UA-XXXXXX-1 with your analytics code.

    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

    Then you can add the tracking code in the "Additional Settings" of the form, where you replace the /goals/enquiry-sent with whatever goal page you have defined (Ref 2):

    on_sent_ok: "_gaq.push(['_trackPageview', '/goals/enquiry-sent']);"

    This now works consistently across all my websites. Hope this helps!


    References to above procedure:
    Ref 1) https://developers.google.com/analytics/devguides/collection/gajs/
    Ref 2) http://www.creare.co.uk/goal-tracking-contact-form-7

  6. Aaron Dicks
    Posted 2 months ago #

    Hi everyone,
    Firstly, thanks for referencing the article I wrote (here on Impression).

    I wanted to drop by for future visitors to help clarify any issues on this topic - I've subscribed to posts via email. Alternatively there's a comment section under the article.

    @Roundcape. I am always weary with pushing additional page views on your website in the way you have identified above - this will double those page views in your Audience Overview in Google Analytics and may be misleading. Events (as per my article) are a much better solution as the double page views are avoided, plus you can also store additional data - such as category, action, label, value).

    To sum up, if you're using Universal Analytics, the correct text to paste into Additional Settings will look something like this;

    on_sent_ok: "ga('send', 'event', 'category', 'action);"


  7. platypidesigns
    Posted 2 months ago #


    I too have setup my Contact Form 7 the way it has been outlined in the article: https://www.impression.co.uk/blog/825/event-tracking-wpcf7-universal-analytics/

    I have all the settings in place but it will not track. I know I'm using Universal GA so that's fine. I have the right code in the Additional settings of the wordpress Contact Form 7 plugin, the goal setup in GA and it's not tracking.

    Any ideas, thoughts?

    Is there something we should be looking for in the code that might tell us if we have things right?


  8. Aaron Dicks
    Posted 2 months ago #

    Hi platypideigns
    Are these events tracking in Google Analytics under Behaviour > Events?
    Have you set up your goals exactly matching your events?

    You might also need to check out whether there are any JavaScript issues on the page when you click submit, too. If you use a browser with a console (FF, Chrome, etc), are there any errors there?


  9. Aaron Dicks
    Posted 2 months ago #

    Also, I have noticed I missed a single quote off the end of that code snippet - could you confirm whether you spotted that?
    It should be:

    on_sent_ok: "ga('send', 'event', 'category', 'action');"

    So for an enquiry form submission, copy this exactly

    on_sent_ok: "ga('send', 'event', 'Enquiry', 'Submit');"



You must log in to post.

About this Plugin

About this Topic