Embedded Scorecard events in the parent window
This article assumes you have already embedded your Scorecard within your website using the guide found here.
The embedded Scorecard notifies the parent window of important events during the flow of leads moving through your Scorecard.
As a developer, you can subscribe to these notifications to fire analytics events or change the state of your website or app. We use window.postMessage()
to post events to the parent window.
You can listen to these events in Javascript with the following example code
window.addEventListener("message", (e) => { const { event, data } = e.data; if (event && event.startsWith('scoreapp_')) { console.log('ScoreApp Event', event, data); } }, false);
Below are the specific events sent along with the data payload:
Lead Form Modal Opened
{ event: "scoreapp_lead_form_modal_opened", data: { scorecard_name: "", scorecard_key: "" } }
Lead
{ event: "scoreapp_lead", data: { email: "", first_name: "", last_name: "", scorecard_name: "", scorecard_key: "" } }
Questions Started
{ event: "scoreapp_questions_started", data: { scorecard_name: "", scorecard_key: "" } }
Questions Finished
{ event: "scoreapp_questions_finished", data: { scorecard_name: "", scorecard_key: "" } }
Question Answered
{ event: "scoreapp_question_answered", data: { question: "", question_ref: "", scorecard_name: "", scorecard_key: "" } }