I have a booking system embedded into website via iframe - I would like to redirect the user to a Thank You page once the booking has been submitted.
There is a receiveMessage being sent to the parent frame from the booking system iframe, wondering if I can use this as the trigger to redirect the page by adding to the code below?
Thanks in advance
window.addEventListener("message", receiveMessage);
function receiveMessage(e) {
if (typeof e.data !== 'string') return;
if (e.data.search('cliniko-bookings-page:confirmed') > -1) {
var dataLayer = window.dataLayer || (window.dataLayer = []);
dataLayer.push({
'event': 'clinikoBookingCompleted'
});
}
}
</script>```
cliniko-bookings-page:confirmedis the criterion, then sure, why not ...? Add it to the end of that if block then. - CBroe<script type='text/javascript'> window.addEventListener("message", receiveMessage); function receiveMessage(e) { if (typeof e.data !== 'string') return; if (e.data.search('cliniko-bookings-page:confirmed') > -1) { var dataLayer = window.dataLayer || (window.dataLayer = []); dataLayer.push({ 'event': 'clinikoBookingCompleted' window.top.location.href = "http://example.com"; }); } } </script>- MarkodataLayer.push({...});, but after. - CBroe