Messaging interface cookie block after 3 questions
-
I’m not a pro, so please don’t judge too harshly. But I could really use some help:
I’ve got a messaging interface integrated within my WordPress site that looks something like this:
<convo data-aspect-ratio="4:3”> <a href="#"><span>View experience</span></a> <script src="#"></script> </convo>
Using postMessage interface and I want to use an event listener to grab event data from the player
window.addEventListener("message", (event) => { console.log(event.data); // e.g. <code>speakeasy:ready</code>, <code>speakeasy:maximise</code>, <code>speakeasy:minimise</code> });
and add a “roadblock after three questions” functionality:
window.addEventListener("message", (event) => { if (event.data.startsWith("speakeasy:response")) { doSomething(event.data); });
I’d like to write it in the following format:
1. On page load, check cookie to see if the user has asked 3 questions
– If so, check whether the user has subscribed to the email list
– If so, show a thanks message
– Else, show the subscription form
– Else, add the player to the page and listen for events via postMessage
2. On each postMessage event, if the event type is “response”
– Increment the responses count on the cookie
– If responses >= 3, remove or disable the player, and
– If subscribed === true, show thanks message
– Else, show subscription form
3. On subscription form submission, set subscribed to true on the cookie`Could you please advice on what would be the best way to tackle this?
Many thanks,
Laura
- The topic ‘Messaging interface cookie block after 3 questions’ is closed to new replies.