Support » Plugin: Contact Form 7 » Contact form 7 and google analytics problem

  • Hi

    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..

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

Viewing 15 replies - 1 through 15 (of 30 total)
  • Same problem here:
    on_sent_ok: “ga(‘send’, ‘event’, ‘Contact Form Content Page’, ‘Verzenden’);”

    Followed instructions from here:
    https://www.impression.co.uk/blog/825/event-tracking-wpcf7-universal-analytics/

    And (re-) started plugin several times…

    Did you enter the code in “additional settings” below your form and email form(s)?
    Check here:
    http://contactform7.com/tracking-form-submissions-with-google-analytics/

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

    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;
    http://www.atlplastic.com/DrFernandoBursteinblog/

    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']);
      _gaq.push(['_trackPageview']);
    
      (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);
      })();
    
    </script>

    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!

    KR
    Siro

    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

    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);”

    Thanks
    Aaron

    Hi,

    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?

    Thanks.

    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?

    Aaron

    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');"

    Aaron

    Hi,

    We used to have the old google analytics code in the additional settings box and it tracked form submissions fake page views with the below code:

    on_sent_ok: “_gaq.push([‘_trackPageview’, ‘/thanks’]);”

    Then we updated to universal analytics and replaced the above code that was in the additional settings box with the below and set up an event goal to match it:

    on_sent_ok: “ga(‘send’, ‘event’, ‘category’, ‘action’, ‘label’);”

    …. but now it doesn’t track form submissions.

    I also tried send pageview /thanks with the new universal code and set the page destination as a goal and still no joy.

    Please can someone help with this? Do we need to implement Roundcape’s procedure first before this will work??

    Any help would be much appreciated.
    Thanks

    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’]);
    _gaq.push([‘_trackPageview’]);

    (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);
    })();

    </script>

    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!

    KR
    Siro

    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

    I ended up setting a Goal and using the setting here, using the UA code;
    http://www.creare.co.uk/goal-tracking-contact-form-7

    I think one of my problems was I was using the old _gaq.push code but using the new UA anilytics code.

    Thanks for your reply – I’ve set this up as a destination goal using the Creare instructions and still no joy.

    If anyone has any other ideas that would be great!

    Thanks,

    @pitterz
    Results on Google Anilytics Goals take 24 to 48 hrs. to show up. Has it been that long since you set it up and did a test form submission?

    Yea it’s been that long and still no joy.

    Any help much appreciated before I remove the form and get a dev guy to code one up?

    Can you post the exact line you added to your Additional Settings in your Contact form, and if you have more then one form make sure it is the one you want to track.
    Can you also post the exact line you put in the Destination field for your Google Goal( you have your Goal type set to destination right)?

    Hey all,

    Very useful thread, so thanks. If you’re still struggling, this may be your problem:

    I was working on a site that had Google Analytics for WordPress installed (by Joost). The developer used this plugin to add Analytics.

    Using the method outlined above (adding the UA event tracking code to CF7 additional settings), the form would not reset or show the “thank you” message.

    I deleted the Joost plugin and added the UA tracking code to the footer manually. After that, everything works just fine.

    So if you’re using any third party plugin to add Analytics code to your site, that could be the problem.

    Hope that helps!

    -Brock

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘Contact form 7 and google analytics problem’ is closed to new replies.