This example triggers a JavaScript function once Riddle iframe result page or lead form is loaded.

Example code

<script>
    function onMessage(event) {
        if (event.data && event.data.riddleEvent) {
            var riddleData = event.data.riddleEvent;
            if ('object' === typeof (riddleData)) {
                if (riddleData.action === 'view-quiz-result') {
                    // Your core here
                }
            }
        }
    }
    window.addEventListener("message", onMessage, true);
</script>