• Resolved OliverC

    (@yan5280)


    I have a few different contact forms (all using contact form 7) and would like to track the submission action on each of them. In the GA tracking code, I added the following to the :

    ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFStandard’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFAdvanced’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFTrainer’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘SnowcatBasic’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘SnowcatEnhanced’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘WinterSurvival’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘GeneralContact’);

    Also, added snippets to individual contact forms. For example, in the winter survival’s additional setting, I added:

    on_sent_ok: “ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘WinterSurvival’);”

    I thought the labels would track only that form, but instead, it’s tracking each form submission 7 times… What should I do?

    Thank you!

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • @yan5280, just remove all that

    ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFStandard’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFAdvanced’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘PFTrainer’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘SnowcatBasic’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘SnowcatEnhanced’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘WinterSurvival’); ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘GeneralContact’);

    from your tracking code. By this, you are sending form submission events on tracker initialization, even without submitting any form. You want to have only

    on_sent_ok: “ga(‘send’, ‘event’, ‘Forms’, ‘Submit’, ‘WinterSurvival’);”

    in every form. That will work

    Here’s the update on this:
    You can easily track successful Contact Form 7 submits in Google Analytics using Google Tag Manager. This uses wpcf7mailsent, required 2017

    Contact Form 7 sends a custom JavaScript event (wpcf7mailsent) on successful form submission, and the form is identified in the Click URL variable, which, for forms, contains the form action property.

    Create two tags and one trigger:

    Tag 1 name: Contact Form 7 – Success Listener
    Tag type: Custom HTML
    HTML:

    <script type=”javascript”>
    var wpcf7Elm = document.querySelector(‘.wpcf7’);
    wpcf7Elm.addEventListener( ‘wpcf7mailsent’, function(event) {
    dataLayer.push({‘event’ : ‘CF7formSubmitted’});
    }, false );
    </script>

    Triggering: All Pages (Page View)

    Tag 2 name: Contact Form 7 – Success Submitted
    Tag type: Universal Analytics
    Track type: Event
    Event Category: Form Submitted
    Event Action: {{Click URL}}
    Event Label: optional
    Event Value: optional
    Triggering: CF7 Form Submitted – cf7mailsent

    Trigger name: CF7 Form Submitted – cf7mailsent
    Trigger type: Custom Event
    Event name: CF7formSubmitted
    Trigger fires on: EVENT matches CF7formSubmitted

    Note case sensitivity.

    People with more free time can create more advanced reporting by adding the following:

    1. Variable (macro) with type JavaScript to extract Form code from {{Click URL}},
      especially valuable if you have the same form appearing on multiple pages
    2. Variable (macro) with type Lookup Table to translate form code into form name.
    Thread Starter OliverC

    (@yan5280)

    @vasili4 Thank you, but that method often blocks the “thank you”/success message after a mail is triggered…

    Thread Starter OliverC

    (@yan5280)

    @averycohen Awesome. Just tested on a website and it worked!!! Thank you so much! If you have a few minutes, would you mind explaining more regarding your notes about the advanced reporting settings? Or would you please point me to any supporting materials/to-do tutorials that may be helpful in that aspect?

    Many thanks!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Track Multiple Forms with Google Analytics Events’ is closed to new replies.