Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
868 B
3
Indexable
Never
<script src="https://js.chilipiper.com/marketing.js" type="text/javascript"></script>
<script>
var cpTenantDomain = "domain"; // replace with your subdomain
var cpRouterName = "inbound_router"; // replace with the router's name
var cpHubspotFormIDs = "da31796f-16ed-4191-81a8-baa60ee0c8c2"; //replace with HubSpot FormID
window.addEventListener("message", function (event) {
   if (event.data.type === "hsFormCallback" && event.data.eventName === "onFormSubmit") {
      if (cpHubspotFormIDs.length > 0 && !cpHubspotFormIDs.includes(event.data.id)) return;
      var lead = {}; for (var key in event.data.data) { lead[event.data.data[key].name] = event.data.data[key].value; }
      if(Object.keys(lead).length <= 1){lead = event.data.data;}
      ChiliPiper.submit(cpTenantDomain, cpRouterName, {
         map: true,
         lead: lead
      });
   }
});  
</script>