You can use the quform:successStart JavaScript hook to send an event to Google Analytics when the form is submitted.

Check the Google Analytics code you added to your site to see if you are using the newer gtag.js integration or the older analytics.js one. Then go to Forms → Settings → Custom CSS & JS and at the Custom JavaScript field enter the code below.

Using gtag.js

1
23
4
5
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {        gtag('event', 'submit', { 'event_category': 'Contact Form' });
    });
});
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {
        gtag('event', 'submit', { 'event_category': 'Contact Form' });
    });
});
  • On line 2, replace the number 1 with the form ID
1
2
3
4
5
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        gtag('event', 'submit', { 'event_category': 'Contact Form' });
    });
});
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        gtag('event', 'submit', { 'event_category': 'Contact Form' });
    });
});

Using analytics.js

1
23
4
5
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {        ga('send', 'event', 'Contact Form', 'submit');
    });
});
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {
        ga('send', 'event', 'Contact Form', 'submit');
    });
});
  • On line 2, replace the number 1 with the form ID
1
2
3
4
5
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        ga('send', 'event', 'Contact Form', 'submit');
    });
});
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        ga('send', 'event', 'Contact Form', 'submit');
    });
});

Using Google Tag Manager

1
23
4
5
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {        dataLayer.push({'event': 'Contact Form'});
    });
});
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {
        dataLayer.push({'event': 'Contact Form'});
    });
});
  • On line 2, replace the number 1 with the form ID
1
2
3
4
5
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        dataLayer.push({'event': 'Contact Form'});
    });
});
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        dataLayer.push({'event': 'Contact Form'});
    });
});

Using Google Analytics Measurement Protocol

1
23
4
56
7
8
9
10
11
12
13
14
15
16
17
18
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {        var params = {
            v: 1,               // Version
            tid: 'UA-XXXXX-Y',  // Tracking ID / Property ID            cid: 555,           // Anonymous Client ID
            t: 'event',         // Hit Type
            ec: 'Contact Form', // Event Category
            ea: 'submit'        // Event Action
        };
 
        $.ajax({
            url: 'https://www.google-analytics.com/collect',
            type: 'POST',
            data: params
        });
    });
});
jQuery(function ($) {
    $('.quform-form-1').on('quform:successStart', function () {
        var params = {
            v: 1,               // Version
            tid: 'UA-XXXXX-Y',  // Tracking ID / Property ID
            cid: 555,           // Anonymous Client ID
            t: 'event',         // Hit Type
            ec: 'Contact Form', // Event Category
            ea: 'submit'        // Event Action
        };

        $.ajax({
            url: 'https://www.google-analytics.com/collect',
            type: 'POST',
            data: params
        });
    });
});
  • On line 2, replace the number 1 with the form ID
  • On line 5, replace UA-XXXXX-Y with your Google Analytics Tracking / Property ID
1
2
3
4
56
7
8
9
10
11
12
13
14
15
16
17
18
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        var params = {
            v: 1,               // Version
            tid: 'UA-XXXXX-Y',  // Tracking ID / Property ID            cid: 555,           // Anonymous Client ID
            t: 'event',         // Hit Type
            ec: 'Contact Form', // Event Category
            ea: 'submit'        // Event Action
        };
 
        $.ajax({
            url: 'https://www.google-analytics.com/collect',
            type: 'POST',
            data: params
        });
    });
});
jQuery(function ($) {
    $('.quform-form').on('quform:successStart', function () {
        var params = {
            v: 1,               // Version
            tid: 'UA-XXXXX-Y',  // Tracking ID / Property ID
            cid: 555,           // Anonymous Client ID
            t: 'event',         // Hit Type
            ec: 'Contact Form', // Event Category
            ea: 'submit'        // Event Action
        };

        $.ajax({
            url: 'https://www.google-analytics.com/collect',
            type: 'POST',
            data: params
        });
    });
});
  • On line 5, replace UA-XXXXX-Y with your Google Analytics Tracking / Property ID
Be inspired. © 2018 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy