Demo Form Landing

 avatar
user_7274535
plain_text
a year ago
1.0 kB
10
Indexable
Never
<script src="https://js.na.chilipiper.com/marketing.js" type="text/javascript" async></script>
 <script> const cpTenantDomain = "precoro"; // REPLACE
  const cpRouterName = "inbound_router_demo_landing"; // REPLACE
  //
  // No changes needed from this point
  var date = new Date();
var offset = date.getTimezoneOffset();// Get UTC offset from browser
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  // Listen for form submitted message
  window.addEventListener("message", (event) => {
    if (event.data.type === "hsFormCallback" && event.data.eventName === "onFormSubmit") {
      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;}
      console.log(lead);
      lead.timezoneOffset = offset;
      lead.timezone = timezone; 
      ChiliPiper.submit(cpTenantDomain, cpRouterName, {
        map: true,
        lead: lead, 
      });
    }
  });</script>