Following the example for implementing parent notifications, I have the following code to write to console.log all Calendly events:
<html>
<body>
<h1>Calendly Embed Test</h1>
<div id="calendly-embed" style="min-width:320px;height:700px;"></div>
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
<script>
Calendly.initInlineWidget({
url: ' INSERT YOUR CALENDLY URL EVENT HERE]',
parentElement: document.getElementById('calendly-embed'),
prefill: {},
});
</script>
<script>
function isCalendlyEvent(e) {
return e.origin === "https://calendly.com" && e.data.event && e.data.event.indexOf("calendly.") === 0;
};
window.addEventListener("message", function(e) {
if(isCalendlyEvent(e)) {
/* Example to get the name of the event */
console.log(">> Event name:", e.data.event);
/* Example to get the payload of the event */
console.log(">> Event details:", e.data.payload);
}
});
</script>
</body>
</html>
Running the above code renders the embedded Calendly perfectly, however, it does not write anything to the console window when events occur. Can you shed some light as to why nothing is happening?
Thanks!