Skip to main content

How to track bookings with Google Tag Manager

Connect your Google Tag Manager container to your Amenitiz website and booking engine, and track bookings and revenue from your campaigns as GA4 ecommerce events.

Overview

Connect your own Google Tag Manager container to your Amenitiz website and booking engine. Your container then receives every step of the booking (rooms viewed, added to cart, checkout started, booking paid) as standard GA4 ecommerce events.

You, or your marketing agency, can see which campaigns bring bookings and revenue, not only visits.

The app is free. Your container loads on your Amenitiz website and booking engine. If you don't have an Amenitiz website, it loads on your booking engine, including one embedded on your own website.

⚠️ Before you start

  • A Google Tag Manager account and a web container. Create one for free at tagmanager.google.com if you don't have one yet.

  • Your container ID. It looks like GTM-XXXXXXX and is shown at the top of your Tag Manager workspace.

  • If your booking engine is embedded on your own website: your website address filled in under Property › General.


Step-by-step guide

1. Activate the app

  1. Go to Marketplace in your admin sidebar.

  2. Under Discover all apps, click See all and open Google Tag Manager.

    This shows how to open the Google Tag Manager app from Marketplace → Discover all apps → See all

    This shows how to open the Google Tag Manager app from Marketplace → Discover all apps → See all.

  3. Click Activate.

  4. At Step 4, paste your container ID (for example GTM-AB12CD3) in Google Tag Manager container ID.

  5. Click Save.

    This shows how to click Activate, paste your container ID in Google Tag Manager container ID and click Save

    This shows how to click Activate, paste your container ID in Google Tag Manager container ID and click Save.

Your container now loads on your Amenitiz website and booking engine. To stop it, deactivate the app: the container ID is removed.

📌 Note

If you see Enter a valid Google Tag Manager container ID, check that the ID starts with GTM- and that you copied the container ID, not a GA4 measurement ID (G-XXXXXXX).


2. Set up GA4 in your container

The booking engine sends standard GA4 ecommerce events, so GA4 can read them as they are.

  1. In Tag Manager, add a Google tag with your GA4 measurement ID (G-XXXXXXX), triggered on Initialization - All Pages.

  2. Add a GA4 Event tag. Event name: {{Event}}. Tick More settings › Ecommerce › Send ecommerce data, data source Data Layer.

  3. Give it a Custom Event trigger with event name view_item_list|add_to_cart|remove_from_cart|begin_checkout|purchase and Use regex matching ticked.

  4. Click Submit to publish the container.

You can add Google Ads conversion or Meta Pixel tags on the same events, for example a Google Ads conversion on purchase.


3. Keep visits and bookings in one session

If your website is on your own domain (for example www.myhotel.com) and your booking engine is on an Amenitiz domain, Google Analytics sees two different sites unless you link them.

  1. In Google Analytics, go to Admin › Data streams and open your web stream.

  2. Click Configure tag settings › Configure your domains.

  3. Add your website domain and the booking engine domain shown in the Google Tag Manager app in Amenitiz.

    This shows where the Google Tag Manager app displays your booking engine domain to add to the Google Analytics cross-domain settings

    This shows where the Google Tag Manager app displays your booking engine domain to add to the Google Analytics cross-domain settings.

Without this, bookings show up as coming from your own website instead of the campaign that brought the guest.


Booking engine embedded on your own website

If your booking engine is shown inside your own website (in an iframe), your container cannot run inside it: browsers block its cookies there, and the visit would be split in two. Instead, the booking engine sends each event to your website, and the container on your website picks it up.

  1. Go to Property › General and fill in Your website address. The Google Tag Manager app in Amenitiz shows which address the events are sent to.

  2. Install your Google Tag Manager container on your website, on the page that shows the booking engine.

  3. Add the snippet below to that page, after your Tag Manager code. Replace https://BOOKING-ENGINE-ADDRESS with https:// followed by the booking engine domain shown in the Google Tag Manager app in Amenitiz (the same one as in step 3), for example https://myhotel.amenitiz.io. If this address is wrong, no events arrive and no error is shown.

<script>
window.addEventListener("message", function (event) {
if (event.origin !== "https://BOOKING-ENGINE-ADDRESS") return;
var data = event.data;
if (!data || data.source !== "amenitiz-booking-engine") return;
var message = Object.assign({}, data);
delete message.source;
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push(message);
});
</script>

The events then reach your website's dataLayer exactly as described below, and the tags from step 2 work unchanged.


Avoid double tracking

The app loads your container for you. Loading it a second time, or sending to the same GA4 property from two places, counts every visit and booking twice.

  • Don't also paste your Tag Manager code into your Amenitiz website. If you added the GTM snippet by hand in a Custom code block, remove it when you activate the app.

  • Don't keep the Google Analytics app on if your container already sends to GA4. If your container has a Google tag with the same measurement ID, deactivate the Google Analytics app in the Marketplace and let your container handle GA4.

  • One container per page. If your booking engine is embedded on your own website, the container goes on your website only, as described above.

To check, open Preview in Tag Manager: each event should appear once, and your container ID should appear only once in the Tag Assistant panel.


Using the Google Analytics app instead

If you only have the Google Analytics app active (no Google Tag Manager app), the same ecommerce events are sent straight to your GA4 property. There is nothing else to set up.

This does not work when the booking engine is embedded in an iframe on your website: use the Google Tag Manager app for that.

If both apps are active, ecommerce events go only to your Tag Manager container, never twice. Page views can still be counted twice if your container also has a Google tag for the same GA4 property: see Avoid double tracking above.


The events you receive

Event

When it is sent

view_item_list

The search results show, once per search. One item per room and rate.

add_to_cart

The guest adds a room or increases the number of rooms.

remove_from_cart

The guest removes a room or lowers the number of rooms.

begin_checkout

The guest reaches the payment step.

purchase

The booking is confirmed. transaction_id is the Amenitiz booking ID.

Each event carries currency and items. add_to_cart, remove_from_cart, begin_checkout and purchase also carry value; view_item_list carries item_list_id and item_list_name instead. Item IDs stay the same from the start to the end of the booking:

Item

item_id

Room

room_<room id>, with the rate name in item_variant

Extra

extra_<extra id>

Insurance

insurance

City tax

city_tax

Events also include hotel_id, and where relevant nights, adults and children.

✅ No guest personal data

Events never include guest names, emails or phone numbers.


Consent and privacy

Your Amenitiz website and booking engine apply Google Consent Mode defaults before your container loads, so tags respect the guest's consent choice. As the owner of the container and the analytics account, you are responsible for the tags you add to it and for your cookie banner settings.

If your booking engine is embedded on your own website, these defaults don't apply there: consent depends on your own website's cookie banner.


Check that it works

  1. In Tag Manager, click Preview and open your website or booking engine.

  2. Search for dates, add a room and go to the payment step.

  3. In the Tag Assistant panel, you should see view_item_list, add_to_cart and begin_checkout, each with an ecommerce object.

  4. In GA4, open Reports › Realtime or Admin › DebugView to see the events arrive.


FAQs

Nothing shows up in Tag Manager or GA4. What should I check?

Check the container ID in the app, and that your container is published (Submit), not only saved.

A cookie banner may block tags until the guest accepts. Accept cookies when you test.


My booking engine is embedded on my website and no events arrive. Why?

Check Your website address under Property › General, that your container is on the page showing the booking engine, and that the snippet is installed with the right booking engine address.


Every visit or booking is counted twice. Why?

Look for a second copy of your container in a Custom code block on your Amenitiz website, or a Google Analytics app still active next to a GA4 tag in your container. See Avoid double tracking above.


Is any guest personal data sent to my container?

No. Events never include guest names, emails or phone numbers.

Did this answer your question?