# How to track conversions with Google Analytics 4 (GA4)?

How can I check if visits to my website convert into reservations? How to use Google Analytics 4 with HBook to compare visits to my website and finalization of reservations?

<a id="set-up-your-google-analytics"></a>

## Set up your Google Analytics

If you haven't a Google Analytics account set, with GA4 property and Data collection set, then follow the steps below, which are detailed in this article: [https://support.google.com/analytics/answer/9304153](https://support.google.com/analytics/answer/9304153) :

1. Create an Analytics account
2. Create a new Google Analytics 4 property
3. Add a data stream for your "Web"
4. Set up data collection for your website:
  - If you wish to use [Google Site Kit](https://wordpress.org/plugins/google-site-kit/), you will connect your Google Site Kit to your Google Analytics Property at this step. Google Site Kit takes care of adding the code on your website pages.
  - Don't forget the checkbox for "User Data Collection Acknowledgement" (in Admin - Data collection and modification - Data collection). No data will be collected until you acknowledge it.

<a id="organize-the-booking-steps-in-hbook"></a>

## Organize the booking steps in HBook

HBook allows you to split the booking process in different steps that can be done on different pages:

<a id="step-1-search-form-page-accommodation-booking-page"></a>

### Step 1 - Search form page / Accommodation booking page

You will set the redirection to your "Main booking page" with the parameters "search\_only" and "redirection\_url".

- On a **global** search form, you can set that the **results of the search** will be displayed on a different page. The user enters check-in date and check-out date, number of guests (if relevant) and is redirected to a different page. Here is an example of shortcode for this behaviour: `[hb_booking_form search_only="yes" redirection_url="https://www.abc.com/main-booking-form"]`

- On a **global** search form, you can set that the user is redirected to a different page only **once he has selected the accommodation** he wishes to book. Here is an example of shortcode for this behaviour:  
`[hb_booking_form redirection_url="https://www.abc.com/main-booking-form"]`
- On an **accommodation** form, you can set that the user is redirected after the results of his search. Here is an example of shortcode for this behaviour:  
`[hb_booking_form accom_id="123" redirection_url="https://www.abc.com/main-booking-form"]`

<a id="step-2-main-booking-page-extra-services-customer-details-and-payment"></a>

### Step 2 - Main booking page : Extra-services, Customer details and Payment.

You will set the redirection to your "Thank you page" with the parameter "thank\_you\_page\_url". On this second page (the "Main booking page"), you will have a booking form, and you can set a redirection for the last step. Here is an example of shortcode for this behaviour:  
`[hb_booking_form thank_you_page_url="https://www.abc.com/thank-you-page"]`

<a id="step-3-thank-you-page"></a>

### Step 3 - Thank you page.

On this page, you will have a shortcode \[reservation\_summary\]. The user will be redirected to this page only when the reservation is finalized, be it that an online payment is required or not.

<a id="set-up-the-conversions-in-ga4"></a>

## Set up the conversions in GA4

With the above, we can create conversions in Google Analytics 4, for example, to get an idea of how many users actually go throw the different steps. As an example, here is how to set a conversion for users reaching the "Thank you page", which is when the reservation process has been completed (with or without online payment).

- In **Admin - Data display - Events**, you will create an event as follows:  
![create_event_analytics.png](./attachments/create_event_analytics.png)
- In **Admin - Data display - Conversions**, you will set that this event is to be considered as a conversion:  
![create_conversion_name_analytics.png](./attachments/create_conversion_name_analytics.png)

You can **create different conversion events**, to measure the page views of each step of the booking process. You will create a new event for each measurement.

For example, you can create an event "main\_booking\_page" and set is as a different conversion: by doing so, you compare how many visitors land on your website (automatically done with "Page Views" counts, switched on by default on GA4) with how many visitors reach your "Main booking page" and how many actually finalize their booking.

You can as well **set additional parameters** for a finer tuning of what you are tracking.

For example, let's say I wish to check how many finalized reservation are done from my page where I have an Accommodation list (in this example, the URL contains "accommodation-list"):

![conversion_from_accom_list.png](./attachments/conversion_from_accom_list.png)

<a id="adding-other-google-analytics-scripts-in-hbook"></a>

### Adding other Google Analytics scripts in HBook

For your information, HBook calls 2 different JavaScript functions during the booking process. You can use them to run specific scripts:

- [hbook\_show\_accommodation\_list](https://maestrel.atlassian.net/wiki/spaces/HD/pages/34734482/Plugin+customization#hbook_show_accom_list)
- [hbook\_reservation\_done](https://maestrel.atlassian.net/wiki/spaces/HD/pages/34734482/Plugin+customization#hbook_reservation_done)