Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
929 B
2
Indexable
Never
<script src="https://js.chilipiper.com/marketing.js" type="text/javascript"></script>
<script>
var cpTenantDomain = "komodor"; // replace with your subdomain
var cpRouterName = "events_router"; // replace with the router's name
var lead = {};
window.addEventListener("message", function (event) {
   if (event.data.type === "hsFormCallback") {
       if (event.data.eventName === "onFormSubmit") {
           for (var key in event.data.data) {
               if (Array.isArray(event.data.data[key].value)) {event.data.data[key].value = event.data.data[key].value.toString().replaceAll(",",";");}
               lead[event.data.data[key].name] = event.data.data[key].value;
           }
           if(Object.keys(lead).length <= 1){lead = event.data.data;}
       } else if (event.data.eventName === "onFormSubmitted") {
           ChiliPiper.submit(cpTenantDomain, cpRouterName, {map:true,lead:lead});
       }
   }
});
</script>