Redirecting clients to a 'Thank You' page after a successful transaction from the booking widget is a simple yet powerful way to enhance the user experience and acknowledge their actions. In this article, we will discuss how you can accomplish this.
Things to know:
- The embedding of the code should be done on your end by a developer
- The code provided is a template and will require your developer to add the necessary logic to redirect the client to the 'Thank You' page
We've made this API available for your developer to incorporate into your website. This code can be used to notify you of any transactions on the booking widget and then redirect the client to your custom 'Thank You' page.
Please see the code:
try { window.onmessage = (event) = { if (event) { if (typeof event === "object") { if (event.data && event.origin === 'https://www.mytime.com') { const eventData = event.data; /** * Possible events * * mtPurchaseCompletedEvent_service * mtPurchaseCompletedEvent_membership * mtPurchaseCompletedEvent_gift_card * mtPurchaseCompletedEvent_package */ const knownEventPrefix = 'mtPurchaseCompletedEvent'; const serviceEventSuffix = 'service'; const membershipEventSuffix = 'membership'; const giftCardEventSuffix = 'gift_card'; const packageEventSuffix = 'package'; if (typeof eventData === "string") { if ( eventData && eventData.indexOf(knownEventPrefix) === 0 ) { if (eventData.indexOf(knownEventPrefix + '_' + serviceEventSuffix) === 0) { // service event // you can write your custom redirect code here, knowing that a Service was booked console.log('service'); } if (eventData.indexOf(knownEventPrefix + '_' + membershipEventSuffix) === 0) { // membership event // you can write your custom redirect code here, knowing that a Membership was purchased console.log('membership'); } if (eventData.indexOf(knownEventPrefix + '_' + giftCardEventSuffix) === 0) { // gift card event // you can write your custom redirect code here, knowing that a Gift Card was purchased console.log('gift card'); } if (eventData.indexOf(knownEventPrefix + '_' + packageEventSuffix) === 0) { // package event // you can write your custom redirect code here, knowing that a Package was purchased console.log('package'); } } } } } } }; } catch (e) { console.error("Could not set up widget communication"); }
Once completed, whenever a client completes a booking or purchase, they will be redirected to your custom thank you page.
For more information, contact us at support@mytime.com or (385) 233-6964.