Note: check out our event overview here to find out which events are fired by each Riddle Type.
Two simple event listener examples.
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);
Example 1 triggers a JavaScript function once Riddle iframe result page or lead form is loaded.
Example 2 triggers a JavaScript function and shows a hidden text once Riddle iframe result page or lead form is loaded.
We are working on a full list of events but until that is finished, here is an easy way to see all the events your Riddle is generating (please note that the events are different for each Riddle type).
Just add this line of code to your JavaScript to log all events to your browser console:
function onMessage(event) { if (event.data && event.data.riddleEvent) { console.log(event);} } window.addEventListener("message", onMessage, true);
The 2 most popular events are:
riddleData.action === ‘view-quiz-result’ -> fired when the last question of the quiz was answered
event.data.riddleEvent.label == “INSERT NAME OF Personality Test Result Title” -> fires if a particular result of a personality test was achieved