A Step-by-Step Guide to Setting Up Google Analytics GA4 for Your Hotel Website with GTM
If you’re running a hotel website, it’s crucial to have a good understanding of your website traffic and user behavior. By tracking your website with Google Analytics 4 (GA4), you can gain insights into your website’s performance and make data-driven decisions to optimize your website and increase bookings.
In this article, we’ll go through a step-by-step guide on how to set up GA4 for a hotel website and track key metrics for hotel bookings, including multiple rooms and promo codes.
Step 1: Create a Google Analytics 4 Property for Hotels
The first step is to create a new GA4 property for your hotel website. To do this, go to the Google Analytics website and sign in to your account. Click on the “Admin” button on the bottom left of the page, then click on “Create Property” and follow the prompts to set up your new property.
Step 2: Install Google Tag Manager on Your Hotel Website
Google Tag Manager (GTM) is a tool that allows you to add and manage tracking tags on your website without having to modify your website’s code directly. It’s a powerful tool for tracking user behavior on your website, and it integrates well with GA4.
To install GTM on your website, sign in to your GTM account and create a new container for your hotel website. Follow the prompts to set up your container and then copy the container code snippet.
Next, paste the container code snippet into the header of your website’s HTML code, just above the closing </head>
tag.
Step 3: Set Up GA4 Tags in Google Tag Manager
Now that you have GTM set up on your website, you can create GA4 tags to track user behavior on your website. The simplest way to do this is to use the GA4 tag template in GTM.
To set up a GA4 tag, go to your GTM container and click on “Tags” in the left-hand navigation menu. Click on the “New” button to create a new tag, and select the “Google Analytics: GA4 Event” tag template.
Follow the prompts to set up your GA4 tag. You’ll need to enter your GA4 property ID, which you can find in your GA4 property settings, as well as any event parameters you want to track, such as page views or button clicks.
Step 4: Set Up Custom Data Layer Variables
To track custom data in your GA4 tags, you’ll need to set up custom data layer variables in GTM. These variables allow you to pass data from your website’s code into your GA4 tags.
To set up a custom data layer variable, go to your GTM container and click on “Variables” in the left-hand navigation menu. Click on the “New” button to create a new variable, and select the “Data Layer Variable” variable type.
Enter the name of the data layer variable you want to track, such as checkInDate
or promoCode
, and save the variable.
Step 5: Track Hotel Bookings with GA4
To track hotel bookings with GA4, you’ll need to set up an event tag for your booking confirmation page. This tag will track the details of the booking, such as the check-in and check-out dates, the total cost of the booking, and any promo codes used.
Here’s an example of a data layer code you can use to track a hotel booking with multiple rooms:
<script>
dataLayer = [{
'event': 'hotelBooking',
'transactionId': '12345', // Unique transaction ID
'transactionAffiliation': 'Hotel XYZ', // Store or affiliation name
'transactionTotal': 1200.00, // Total transaction value (3 rooms x 400.00)
'transactionShipping': 20.00, // Shipping cost
'transactionTax': 120.00, // Tax amount (3 rooms x 40.00)
'checkInDate': '2023-06-01', // Check-in date (YYYY-MM-DD)
'checkOutDate': '2023-06-03', // Check-out date (YYYY-MM-DD)
'promoCode': 'SUMMERDEAL', // Promo code used (if any)
'currencyCode': 'USD', // Currency code for the transaction
'items': [{
'name': 'Deluxe Room (John)', // Name or ID of the first room
'price': 400.00, // Price of the item
'quantity': 1, // Quantity purchased (1 room)
'sku': 'DR001', // SKU or code of the item
},
{
'name': 'Standard Room (Lisa)', // Name or ID of the second room
'price': 400.00, // Price of the item
'quantity': 1, // Quantity purchased (1 room)
'sku': 'SR001', // SKU or code of the item
},
{
'name': 'Suite Room (Alex)', // Name or ID of the third room
'price': 400.00, // Price of the item
'quantity': 1, // Quantity purchased (1 room)
'sku': 'SU001', // SKU or code of the item
}]
}];
</script>
In this example, the data layer includes the following parameters:
event
: The name of the event being tracked, which in this case is ‘hotelBooking’.transactionId
: A unique identifier for the hotel booking transaction.transactionAffiliation
: The name of the hotel or booking site where the transaction took place.transactionTotal
: The total value of the transaction, including room charges, taxes, and fees.transactionShipping
: The cost of shipping or other fees associated with the transaction.transactionTax
: The amount of tax charged on the transaction.checkInDate
: The check-in date for the hotel booking.checkOutDate
: The check-out date for the hotel booking.promoCode
: The promo code used (if any) for the hotel booking.currencyCode
: The currency code used for the transaction.items
: An array of items purchased as part of the hotel booking, which in this case includes details for one room.