• Hi I have 2 contact forms on my site (request quote id 227 & contact us id 229) I cant seem to get google analytics goal tracking to pick up when the contact form is completed using wpcf7mailsent
    (i normally just track a thankyou page, but apparently contact form 7 works differently)
    I’ve added the following code to the header.php

    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘227’ == event.detail.contactFormId ) {
    ga( ‘send’, ‘event’, ‘Quote Form’, ‘submit’ );
    }
    }, false );
    </script>

    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘229’ == event.detail.contactFormId ) {
    ga( ‘send’, ‘event’, ‘Contact Form’, ‘submit’ );
    }
    }, false );
    </script>

    then set up 1 goal in analytics to pick up
    category “Contact Form”
    Action “submit”

    another goal
    then set up the goals in analytics to pick up
    category “Quote Form”
    Action “submit”

    am i missing something I don’t get any goals tracked

    • This topic was modified 7 years, 1 month ago by ecowindows.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you see the events recorded in the Analytics Dashboard? (Behaviour > Events)

    Thread Starter ecowindows

    (@ecowindows)

    Hi thanks for the reply.
    No im not seeing anything in the Events 0
    and the goals are 0

    I wanted to set a goal up for each of the 2 forms?

    Yea, if the event isn’t being recorded in the Analytics dashboard, there’s nothing for the Goal to report on.

    First thing to confirm is how you’re testing. Remember, if you have an IP address filter to block your own network, you’ll need to use a new View without the filter applied. Also remember that most WP Analytics plugins remove tracking for logged in admins, so you’ll need to be logged out or incognito for your own testing. Also remember some ad blockers blog Analytics too. Just need to be sure that there’s nothing blocking the transmission of data as the problem.

    Had a chance to look at your specific page code. No event is, in fact, being sent. You’re using the newest Global Site Tag for tracking which requires different syntax for sending events to GA, so you’re going to need to adjust your eventlistener sending code a bit.
    https://developers.google.com/analytics/devguides/collection/gtagjs/sending-hits

    Hope that solves the problem!

    Paul

    Thread Starter ecowindows

    (@ecowindows)

    Hi Paul

    I received both your tests thanks.

    The google tracking code has been working I am seeing visits to the site.

    I a bit confused with this event tracker/form submit tracker. I just copied the new code from contact form 7 help page. I’m not really sure how it works.

    I added the following code to the header.php (should it be in funtions.php ?? there was 2 examples of how to do it?)

    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘227’ == event.detail.contactFormId ) {
    ga( ‘send’, ‘event’, ‘Quote Form’, ‘submit’ );
    }
    }, false );
    </script>

    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘229’ == event.detail.contactFormId ) {
    ga( ‘send’, ‘event’, ‘Contact Form’, ‘submit’ );
    }
    }, false );
    </script>

    • This reply was modified 7 years, 1 month ago by ecowindows.
    • This reply was modified 7 years, 1 month ago by ecowindows.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Google analytics goal tracking’ is closed to new replies.