• 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://www.ads-software.com/plugins/contact-form-7/

Viewing 15 replies - 16 through 30 (of 30 total)
  • I just followed the explanation from ‘impression.co.uk’ and submitted my contact forms myself. Now I need to wait 24~48 hours to see if the submissions got tracked.

    @bmcgoff / Brock: with Google Analytics for WordPress installed (by Joost) you likely mean Yoast. Just add this in here so this threat can also get found by that keyword.

    Unfortunately you did not indicate which version of that plugin was used. I use “Google Analytics by Yoast” version 5.0.5 and I have Universal tracking enabled. When I submit the contact form it does show the “thank you” message.

    On the flip side, I don’t see my the CF7 additional settings code being added to the page source. So I’ll wait and see if there is any goal being tracked over the next few days.

    JP

    @bmcgoff / Brock: an additional note. I just wrote I did see the “thank you” message after submitting the form. I have been able to reproduce the issue that you don’t see that message though. Here is the reason:

    The plugin “Google Analytics by Yoast” has a setting to “Ignore users” (by role) to prevent your page views being tracked while you work on the website. It does this by stripping out the Google Analytics tracking code for ignored users that are logged in to WordPress.

    This means that if you submit the contact form while you are logged in as an ‘ignored user’, there is no ‘ga’ tracking code but CF7 still submits the form and still triggers the ‘ga’ event. This results in an error and you don’t see the “thank you” message. If you then look in your browsers console (F12) on the error tab you see an error:

    ReferenceError: ga is not defined
    ga(‘send’, ‘event’, ‘Contactformulier’, ‘Verzonden’);

    Hope this explains the problem you described.

    Now I still need to wait 24~48 hours to see if my form submissions are being tracked.

    Regards
    JP

    This is sorted now thanks everyone!

    It took me a while to get back on my previous post but my CF7 submissions are correctly tracked as goals. I used the CF7 guide from impression.co.uk and I also use the “Google Analytics by Yoast” plugin version 5x with Universal tracking enabled and

    Pitfalls when it doesn’t track
    – The ignore user setting in the “Google Analytics by Yoast” plugin
    – A Google Analytics filter that excludes your own IP address
    – …

    Weird

    This original code stopped working, it produced the error “ga is not defined” again. Ihad to replace the first part to get it working again.

    Original (stopped working)
    on_sent_ok: “ga(‘send’, ‘event’, ‘category’, ‘action’);”

    New one
    on_sent_ok: “__gaTracker(‘send’, ‘event’, ‘category’, ‘action’);”

    Not sure when this happened, maybe after an update of the yoast analytics plugin.

    @john-pierre Cornelissen: With the last version of Yoast Google Analytics and CF7 your code works fine. Thanks

    The code:
    on_sent_ok: "__gaTracker('send', 'event', 'category', 'action');"

    @uomopalese

    Thank you, I know that is the code I use now.
    But it used to be ga(.. rather then __gaTracker(…

    Do you know if this is caused by a change from Analytics or from the Yoast plugin?

    thx
    JP

    @john-pierre Cornelissen

    Hi, for what i see, there is no trace of your code in the google analytics guide https://developers.google.com/analytics/devguides/collection/analyticsjs/events;
    I contacted support on the Yoast Analytics site, I guess they will answer in one business day, i will let you know their answer.

    Thanks again @uomopalese,

    After some creative Googeling I found it
    https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#renaming

    Then I did some further searching and found this thread
    https://www.ads-software.com/support/topic/note-change-of-global-function-ga-_gatracker

    So yes the function is changed by an update of the Yoast Analytics plugin. I am glad it works again but am slightly annoyed that this wasn’t in the plugin release notes and I only noticed it after testing my contact form after an update of that plugin.

    thanks
    JP

    Thanks @john-pierre Cornelissen

    Yoast support has kindly answered that they “can’t give personal support for our free plugins” (and i understand this).
    Just as additional information, i dug by myself in the plugin folder, and i found out that these two files:

    • frontend/class-universal.php (line 165 and subsequent)
    • frontend/vews/tracking-universal.php

    are both written with the new “__gaTracks” code, in accordance with the google guideline, as you properly reported.

    I think Yoast would have renamed the JS object to keep it compartmentalised from other JS Google Analytics plugins. I’ll make a note to update my blog post to reflect this, thanks!

    Hi
    I tried the new “__gaTracks” code but that broke the confirmation message for some reason. When I use the new code I don’t get a confirmation message when I press the button to send my message. When I go back and change to the “ga” code everything works fine! Expect that it doesn’t show up in Analytics of course…..

    It would be fantastic if Contact Form 7 would create a solution that “just worked” As it is right now the web is full of solutions but not one of them is working!

    Please help!
    //Per

    https://www.pocketogram.se

    @adeb,

    I looked at the page source of pocketogram.se and I don’t think it uses the Analytics by Yoast plugin.

    The Analytics code that is in that page uses the ‘ga’ function (as per the line that contains: //www.google-analytics.com/analytics.js’,’ga’)

    That means you need to use the ‘ga’ code and not the ‘__gaTracks’ code.

    For it to show up in Analytics you may have to wait a day or so. You did create a goal in Analytics as explained here, right?

    Regards
    JP

    Ignore (I’m just unsubscribing).

    Hi John-Pierre

    I installed the Analytics by Yoast plugin while testing but when the “__gaTracks” code broke the confirmation message in the contact form I went back to “ga” and deinstalled the Analytics by Yoast plugin.

    //Per

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