Need Form Url on submission email in Episerver form

38 views Asked by At

I have a custom google tag manager element in episerver forms GTM Element

Here's the .js changes

if (typeof $$epiforms !== 'undefined') {
$$epiforms(document).ready(function myfunction() {
    $$epiforms(".EPiServerForms").on("formsSubmitted", function (event) {
        if (event.isFinalizedSubmission && event.isSuccess) {
           if (typeof dataLayer !== 'undefined') {
               var currentForm = $$epiforms(this).get(0);
               $(currentForm).find(".google-tag-manager-form-element").each(function () {
                   var googleTagManager = $(this);
                   var label = googleTagManager.children(".google-tag-manager-form-element__label").val();
                   var action = googleTagManager.children(".google-tag-manager-form-element__action").val();
                   var category = googleTagManager.children(".google-tag-manager-form-element__category").val();

                dataLayer.push({
                    'event': 'formSubmit',
                    'category': category,
                    'action': action,
                    'label': label
                });
            });
            }
        }
    });
});

}

The requirement is to have this GTM element as hidden elements & bind these to the submission form url which will be a part of the submisssion email.Here's an instance of the same: Form Submission Email

I am new to GTM within Episerver form & so any input is appreciated. Thanks.

0

There are 0 answers