Support Log in

53. Google Tag Manager Integration

Developer Guide
Prefer video? Watch the Form Forge tutorials 9 short guides covering every feature Watch

Track form events in Google Tag Manager for analytics and conversion tracking.

Push Form Events to the Data Layer

php
add_action( 'wp_footer', function() {
    if ( ! class_exists( 'FORMFORGE_Core' ) ) return;
    ?>
    <script>
    window.dataLayer = window.dataLayer || [];

    document.addEventListener( 'formforge:submitted', function( e ) {
        window.dataLayer.push({
            'event': 'formforge_submission',
            'formId': e.detail.formId,
            'formTitle': e.detail.formTitle,
            'submissionId': e.detail.submissionId
        });
    } );

    document.addEventListener( 'formforge:validation_error', function( e ) {
        window.dataLayer.push({
            'event': 'formforge_error',
            'formId': e.detail.formId,
            'errors': e.detail.errors
        });
    } );

    document.addEventListener( 'formforge:step_change', function( e ) {
        window.dataLayer.push({
            'event': 'formforge_step',
            'formId': e.detail.formId,
            'step': e.detail.currentStep,
            'totalSteps': e.detail.totalSteps
        });
    } );
    </script>
    <?php
} );

GTM Trigger Configuration

Create a Custom Event trigger in GTM:

Trigger NameEvent NameFires On
Form Forge Submissionformforge_submissionAll Custom Events
Form Forge Stepformforge_stepAll Custom Events
Form Forge Errorformforge_errorAll Custom Events

Google Analytics 4 Conversion Tag

Create a GA4 Event tag in GTM:

text
Tag Type: Google Analytics: GA4 Event
Event Name: form_submission
Parameters:
  form_id: {{DLV - formId}}
  form_title: {{DLV - formTitle}}
Trigger: Form Forge Submission

Forge AI Assistant Online

Hi! I'm the Form Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs