I am trying to set up this simple javascript function to trigger when someone books on a 3rd pary integration.
Should be really easy.
- add “window.addEventListener(“message”, receiveMessage);”
2)add the Function
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’
});
}
}
But I can not get the bloody following to work. ITS SIME JS:
- window.
- .addEventListener
Any advice?
I am using Cliniko iframe for my booking and I need this method so that Google Tags Manager triggers.
If I could add a paid answer option I would.