To have the code for maybe improving the GA4 and GTM conversions accessible for CuHa if customers ask about the conversions
This article is for mainly for CuHa teams (maybe sales), in cases of customers asking how they possibly could improve the converions on GA4 and/or GTM better
Every now and then customers or their marketing people ask how they could make the conversions on online booking better. They most likely are following the conversions with GTM or GA4. At the moment it is not possible to use the so called Thank you-page that is often used for the tags and following conversions.
Unfortunately we can’t promise anything with 100% certainty, but in order to improve the conversions in their analytics, customer could try and add the following code to their website:
<script>
if (window.addEventListener) {
window.addEventListener(“message”, onIframeMessage, false);
}
else if (window.attachEvent) {
window.attachEvent(“onmessage”, onMessage, false);
}
function onIframeMessage(event) {
// Check sender origin to be trusted
if (event.origin !== “https//varaa.timma.fi”) return
console.log(`Timma reservation event data e.g. for Google Analytics consumption`, event.data)
var data = event.data;
if (typeof(window[data.func]) == “function”) {
window[data.func].call(null, data.obj);
}
}
// Function to be called from iframe
function parentFunc(reservationObj) {
console.log(“reservationObj”, reservationObj);
gtag(“event”, “purchase”, {
value: reservationObj.price,
items: reservationObj.items.map((item) => {item_name: item.userService.serviceName, price: item.userService.price})
})
}</script>
After the customer has added the code to their website, we need to add the following code to Hallinta Reservation code box:
if (customer.webpage)
window.parent.postMessage({
func: 'handleTimmaReservationEvent',
obj: {price: priceForTracking, items: combo, customer: reservationInfo}
}, `https://${customer.webpage}`)
// Use target origin instead of *
After the code has been added to Hallinta, customer has to make a slight change to the code: the ${C.reservationPage} part of the code has to be changed into "https//varaa.timma.fi", so the code should look like this:
if (event.origin !== "https//varaa.timma.fi") return
| You may also want to use visual panels to communicate related information, tips or things users need to be aware of. |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|