🚢 Shipped

Communication between the embedded widget and your website

We added JavaScript events that can communicate with your website where the survey widget is embedded. When a survey is completed, the iframe will trigger an event that communicates the completion to your website.

You can use it in code to capture survey completion and send data to third-party tools such as SalesPanel: 


<script>
    /* Add SalesPanel source code here */
</script>

<script>
  window.addEventListener('message', event => {
    try {
      const message = event.data;
      if (message.type === 'ms-survey-completed') {
        const responses = message.data.responses;
        const res = responses.find((response) => response.question_id === "YOUR_QUESTION_ID");
        const customerEmail = res.value;
        $salespanel.push(["set", "identify:email", customerEmail, 'metasurvey']); // here we are sending the event data to SalesPanel
      }
    } catch (error) {
      console.error('An error occurred in event ms-survey-completed:', error);
    }
  });
</script>
Kirill

1 year ago

Activity
Kirill changed status to 🚢 Shipped

1 year ago

No votes yet
Categories
Feature