Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Tracking Goal

Discussion in 'Misc WordPress Requests' started by patrickahmed123, Jan 12, 2018.

  1. patrickahmed123

    Guest

    Tracking Goal, by patrickahmed123

    Im trying to track Contact form 7 Submission, the settings are as follows:
    Goal set-up = custom goal-type=event;
    Goal description = CF7 Submission
    Goal Detail: Category=CF7 Form – Action=Submission – Label=Contact EU

    i pasted this code into functions.php:

    add_action( 'wp_footer', 'mycustom_wp_footer' );

    function mycustom_wp_footer() {
    ?>
    <script type="text/javascript">
    document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( '3907' == event.detail.contactFormId ) {
    ga('send', 'event', 'CF7 Form', 'Submission', 'Trial EU');
    }
    else if ( '3984' == event.detail.contactFormId ) {
    ga('send', 'event', 'CF7 Form', 'Submission', 'White paper EU');
    }
    else if ( '373' == event.detail.contactFormId ) {
    ga('send', 'event', 'CF7 Form', 'Submission', 'Contact EU');
    }
    }, false );
    </script>
    <?php
    }

    Tracking Goal
     
    #1

Share This Page

Monarch Social Sharing Plugin