Adding Gtag to button on Forminator Pro

I need to add gtag to the submit button on my Forminator Pro form. Please, can you advise how to do this?

  • Patrick Freitas
    • FLS

    Hi Jane Mitchell

    Hope you are doing well.

    Wouldn't you mind please extend your query?

    Do you need to append the entire Google tag manager?

    If so, you can give a try on the solution shared on this thread,

    https://wpmudev.com/forums/topic/google-tag-manager-with-forminator#post-1369858

    You will need to change the Form ID on jQuery

    jQuery('form#forminator-module-859').on('forminator:form:submit:success', function (e) {
    dataLayer.push(
    {
    'event': 'form_submit_success',
    'eventCategory': 'Appointment request',
    'eventAction': 'submit',
    'labels': 'submit',
    'eventLabel': pathname || '',
    'eventValue': 'success',
    }
    );
    });
    </script>

    form#forminator-module-859

    You can find the Form ID on

    [attachments are only viewable by logged-in members]

    You will probably need to make some extra change to fit your data/Google Tag configuration.

    You can learn more about on

    https://www.abhishek-tiwari.com/event-tracking-with-data-layer-and-data-attributes/

    However, I can see on the chat you commented that you can define a return onClick.

    <button onclick="return gtag_report_conversion('http://example.com/your-link')">Submit</button>

    If you would like to append this attribute on Forminator button you can use this jQuery.

    jQuery('form#forminator-module-380 .forminator-button-submit').attr('onclick', 'return gtag_report_conversion("http://example.com/your-link")');

    [attachments are only viewable by logged-in members]

    You can add those custom JS on Divi > Theme Option > Integration > Add code to the < head > of your blog for Suggested code other thread, or on Footer for onClick append.

    Let us know if you need any further help on this.

    Best Regards

    Patrick Freitas

  • Rupok
    • Ex Staff

    Hi xxPORRAxx,

    It’s kinda hard to confirm without having a look at your setup first. Can you please contact our Live Chat Support so we can have a look at your current configuration and suggest accordingly? Or, you can create a different forum ticket so we can investigate the issue on your site there. That will be a better approach for troubleshooting the issue you are having.

    Regards,
    Rupok