View Categories

UTM Fields not captured

< 1 min read

Q. UTM fields are not captured as ProspectId is passed twice because of custom implementation
A. The following updated script can be used by the tenant instead for the issue of 2 prospectId being passed in the form submission.


<script>

    document.addEventListener(“DOMContentLoaded”, () => {

        try {

            //Change the formId according to DOM

            var LsqForm = document.getElementById(‘frmrlp-block-41’);

      

            LsqForm.addEventListener(‘submit’, () => {

                var nameEQ = “ORG59130=”;

                var LsqProspectId = ;

      

                if (MXCProspectId) {

                    LsqProspectId = MXCProspectId;

                }

                else {

                    var documentCookiesArray = document.cookie.split(‘;’);

                    for (var i = 0i < documentCookiesArray.lengthi++) {

                        var documentCookiesArrayItem = documentCookiesArray[i];

                        while (documentCookiesArrayItem.charAt(0) ==  ) {

                            documentCookiesArrayItem = documentCookiesArrayItem.substring(1, documentCookiesArrayItem.length);

                        }

      

                        if (documentCookiesArrayItem.indexOf(nameEQ) == 0) {

                            LsqProspectId = documentCookiesArrayItem.substring(nameEQ.length, documentCookiesArrayItem.length);

                            break;

                        }

                    }

                }   



                var prospectElement = document.querySelectorAll(‘[name=”MXHClientProspectId”]’);



                for (var i=0i < prospectElement.lengthi++) {

                    prospectElement[i].remove();

                }

              

                var hiddenElement = document.createElement(‘input’);

                hiddenElement.setAttribute(‘type’‘hidden’);

                hiddenElement.setAttribute(‘name’‘MXHClientProspectId’);

                hiddenElement.setAttribute(‘value’LsqProspectId);

      

                LsqForm.append(hiddenElement);   

            })       

        catch (ex) {

            console.log(ex);

        }   

    });

</script>



Scroll to Top