Funksjon

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.2 kB
2
Indexable
Never
add_action('fluentform_before_form_render', function () {
    static $isloaded = false;
    if($isloaded) {
        return;
    }
    $isloaded = true;
    add_action('wp_footer', function () {
        ?>
        <script>
            (function($){
                if(typeof gtag != 'function') {
                    return;
                }
                var fluentForms = $('form.frm-fluent-form');
                fluentForms.each(function() {
                    var $form = $(this);
                    var formId = $form.attr('data-form_id');

                    gtag('event', 'ViewForm', {
                        'event_category': 'FluentForms',
                        'event_label': 'View Form',
                        'form_id': formId
                    });

                    $form.on('fluentform_submission_success', function() {

                        gtag('event', 'FormSubmission', {
                            'event_category': 'FluentForms',
                            'event_label': 'Form Submitted',
                            'form_id': formId
                        });

                    });

                });

            }(jQuery));
        </script>
        <?php
    });
});