Categories
Academy
/
/
Tracking the reservation widget with Google Tag Manager (Event API)

Tracking the reservation widget with Google Tag Manager (Event API)

Key takeaways
  • Key interactions within the reservation widget can be measured and analyzed.
  • These events can be processed further using, among other things, the Google Tag Manager .

How can you measure visitor traffic in the reservation window (widget) in compliance with GDPR/FADP, even though the widget itself is hosted on foratable.com?

We provide an event API that allows you to read events from the widget and pass them on to your existing monitoring, marketing, or analytics tools.

Depending on the integration, different data structures can be transmitted:
– a simple event name or
– a an event including data context (TrackingContext).

A. Which events are triggered?

The widget triggers various events that map the guest's most important interactions. These events can be captured in GTM, analytics systems, or internal tools, for example.

Currently, the following events are sent:

  • widget_loaded
    The widget has loaded and is ready for use.
  • first_page_reached
    The widget's landing page has been displayed.
  • offers_requested
    The guest has submitted a request (date, time, pax).
  • alternatives_offered
    The widget displays alternative options (e.g., different times).
  • more_alternatives_offered
    The guest is requesting further alternatives.
  • alternative_restaurant_disclaimer_shown
    A notice regarding an alternative restaurant was displayed.
  • restaurant_switched
    The guest has switched to a different restaurant.
  • guest_data_form_reached
    The guest data entry form has been reached.
  • phone_verification_triggered
    Phone verification has been initiated.
  • reservation_done
    A reservation has been successfully created (including pending states such as IVR or credit card).

Important

The event widget_loaded is triggered exactly once – regardless of which page the guest starts on.
A guest can, for example, go directly to the experience selection or the guest data form; in these cases, both the context and the relevant event are transmitted when the page is loaded.

B. What data is included?

In addition to the event name, a data context (TrackingContext) can be transmitted. This object always contains all information already known on the respective widget page.

Data context structure

interface TrackingContext {

  restaurant: TrackedRestaurant‍  request?: {‍    date: IsoDate‍    time?: IsoTime‍    pax?: number‍    experience?: { id: ExperienceId; name: string }‍  }‍  alternativeRestaurant?: TrackedRestaurant‍}‍interface TrackedRestaurant {‍  name: string‍  hash: RestaurantHash‍}‍

Examples of events and data context

first_page_reached



{  "restaurant": {    "name": "Chez Restaurant",    "hash": "68d72f1b12de6520cff29c0f2a3ecf18"  }}

offers_requested

or

more_alternatives_offered



{  "restaurant": {    "name": "Chez Restaurant",    "hash": "68d72f1b12de6520cff29c0f2a3ecf18"  },  "request": {    "date": "2025-07-17",    "time": "13:00",    "pax": 2  }}

alternative_restaurant_disclaimer_shown

or

restaurant_switched



{  "restaurant": {    "name": "Chez Restaurant",    "hash": "68d72f1b12de6520cff29c0f2a3ecf18"  },  "request": {    "date": "2025-07-17",    "time": "11:00",    "pax": 2  },  "alternativeRestaurant": {    "name": "Chez Restaurant (chaines 2)",    "hash": "b49dad61d80214557284eed90d9231e1"  }}

guest_data_form_reached

or

reservation_done



{  "restaurant": {    "name": "Chez Restaurant (chaines 2)",    "hash": "b49dad61d80214557284eed90d9231e1"  },  "request": {    "date": "2025-07-17",    "time": "11:00",    "pax": 2,    "experience": {      "id": 18,      "name": "Restaurant"    }  }}

‍

‍

Q. How do I receive the events?

To receive the events, the widget must be embedded either as a pop-up or an inline iFrame. The individual code is available in your foratable account.

Insert before </body> the following script:

<script async defer src="https://static.foratable.com/iframeContainers.js"></script>

This script ensures that all widgets are initialized correctly.

Integration as a pop-up

‍<button data-lunchgate-modal-url="{{widget-url}}">  Book a table</button>

Integration as an inline widget

<div data-lunchgate-inline-url="{{widget-url}}"></div>

Writing events to Google Tag Manager (dataLayer)

If you use Google Tag Manager, events can be written directly to the dataLayer .

When writing to the dataLayer , foratable adds a prefix to every event:

  • foratable_

Example:

window.dataLayer = window.dataLayer || [];window.dataLayer.push({  event: 'foratable_reservation_done',  tracking_context: {    restaurant: {      name: 'Chez Restaurant',      hash: '68d72f1b12de6520cff29c0f2a3ecf18'    },    request: {      date: '2025-07-17',      time: '11:00',      pax: 2    }  }});

In GTM, you can then set up a Custom Event and trigger tags based on it.

Receiving events via postMessage

Alternatively, you can intercept events via postMessage and forward them to any system.

The following example writes the events to the dataLayer. However, you can also send the data to your own APIs.

<script>‍  /**‍   * event.data format:‍   * {‍   *   type: 'ft-tracking',‍   *   event: 'reservation_done',‍   *   context: { ... }‍   * }‍   */‍  (function () {‍    var handleMessage = function (event) {‍      if (!event.data || event.data.type !== 'ft-tracking') return;‍      window.dataLayer = window.dataLayer || [];‍      window.dataLayer.push({‍        event: event.data.event,‍        tracking_context: event.data.context‍      });‍    };‍    window.addEventListener('message', handleMessage);‍  })();‍</script>

‍

We also recommend this:
Configure booking widget / reservation form
Useful links
Additional resources
Widget API Documentation
More articles on this topic
Couldn’t find what you’re looking for?
Contact our Customer Success Team
office@lunchgate.com