Try   HackMD

Operational Technical Guide for Migrating Google Universal Analytics to GA4

Changelog

Version Date Author Responsible Comments
1.0 25/05/2023 Javier Hernández, Carlos Fernández Raúl Blanco 25/05/2023
1.1 05/06/2023 Javier Hernández, Carlos Fernández Raúl Blanco Improvements and Updates
1.2 13/06/2023 Javier Hernández, Carlos Fernández Raúl Blanco Improvements and Updates

Introduction

The purpose of this document is to provide information about the changes made with the new implementation of GA4 by Neobookings, the new parameters being sent, and how to obtain them.

Prerequisites

  • Google Analytics 4 Property
  • Google Analytics 4 Data Stream
  • Google Tag Manager Account
  • Google Tag Manager Container

Modifications Made to the Booking Engine and Website

The items in the following table are no longer present in the booking engine. All the information is now contained within the 'neobookingsAnalytics' object.

Name Type of data Previous Location New Location
NB object NB neobookingsAnalytics
neobookings object dataLayer.neobookings neobookingsAnalytics
_NeoStepsDataLayer object _NeoStepsDataLayer neobookingsAnalytics.neo_steps
_NeoSearchDataLayer object _NeoSearchDataLayer Deleted

The neobookingsAnalytics object has also been added to the website (when managed by Neobookings), with limited data to enhance overall analytics.

neobookingsAnalytics Object

It's an object that is constructed as the user progresses through the website or booking engine. In other words, depending on the section, it will contain different properties.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
IMPORTANT: The neobookingsAnalytics object cannot be modified by the
client under any circumstances to prevent compatibility issues.

Optional parameters will only be present within the object if they have been assigned a value.

Parameters Optional Type Description Sections
section No string Reports the section of the visit. All (Web and Engine)
language No string Reports the language of the visit. All (Web and Engine)
locale No string Reports the locale of the visit. All (Web and Engine)
hostname No string Reports Domain. All (Web and Engine)
baseurl No string Reports Domain. All (Web and Engine)
origin No string Reports the referral source from a metasearch engine for the visit, or the domain of the site if it's a direct visit. All (Web and Engine)
platform No string Reports type of platform (“booking-engine”, “web”, “callcenter” or “external”) All (Web and Engine)
utm_campaign Yes string Reports Campaign name. All (Engine)
utm_source Yes string Reports the traffic source of the campaign. All (Engine)
utm_medium Yes string Reports the medium of the campaign. All (Engine)
utm_content Yes string Reports the ad version (A/B campaigns) of the campaign. All (Engine)
utm_term Yes string Reports the language of the campaign. All (Engine)
reservation_arrival Yes string Reports the check-in date. All (Engine)
reservation_departure Yes string Reports the check-out date. All (Engine)
reservation_nights Yes string Reports the number of nights. All (Engine)
reservation_numpax Yes string Reports the number of people. All (Engine)
reservation_numrooms Yes string Reports the number of rooms. All (Engine)
hotel_id Yes string Reports the hotel identifier (hash). All but search (Engine)
hotel_name Yes string Reports the hotel name. All but search (Engine)
hotel_zone Yes string Reports the geographical zone of the hotel. All but search (Engine)
google_tracking Yes string Reports if the booking should be tracked by Google. All but search (Engine)
trivago_tracking Yes string Reports if the booking should be tracked by Trivago. All but search (Engine)
tripadvisor_tracking Yes string Reports if the booking should be tracked by Tripadvisor. All but search (Engine)
errors_availability Yes number Reports the quantity of rooms with no availability at the time of page load. step -1 (Engine)
errors_dates Yes number Reports the quantity of errors related to dates at the time of page load. step -1 (Engine)
errors_distribution Yes number Reports the quantity of errors related to PAX distribution at the time of page load. step -1 (Engine)
errors_nights Yes number Reports the quantity of errors related to the number of nights at the time of page load. step -1 (Engine)
errors_price Yes number Reports the quantity of errors related to price at the time of page load. step -1 (Engine)
neo_steps Yes object This is "deprecated" and will be removed in the future; do not use this object. Former _NeoStepsDataLayer. step -1 (Engine)
reservation_amount Yes string Reports the total price of the booking. step -3 and my-booking (Engine)
reservation_roomtype Yes string Reports the name of the room. step -3 and my-booking (Engine)
reservation_id Yes string Reports the booking identifier. my-booking (Engine)
reservation_currency Yes string Reports the currency of the booking. my-booking (Engine)
reservation_callcenter Yes boolean Reports if it's a reservation made from the call center. my-booking (Engine)
reservation_rates Yes string Reports the name of the booking rate. my-booking (Engine)
reservation_numadults Yes string Reports the number of adults in the booking. my-booking (Engine)
reservation_numchildrens Yes string Reports the number of children in the booking. my-booking (Engine)
reservation_numbabies Yes string Reports the number of infants in the booking. my-booking (Engine)
reservation_mode Yes string Reports the booking type. my-booking (Engine)
email Yes string Reports the customer's email. my-booking (Engine)

New Implemented Events

To enhance the measurement of engine metrics, new events have been implemented. These events introduce data into the dataLayer to be later accessed by GTM.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
IMPORTANT: The dataLayer object cannot be modified by the client under any circumstances. The engine adds all necessary data for report generation and other analytics.

Initial DataLayer

Upon initializing the dataLayer variable, a gtm.global event is reported, containing the parameters specified in the following table to complete Analytics information.

Parameters Type Value (example) Platforms
language string "es" Web y motor
page_type string "confirmation" Web and Engine
system_http_status string "200" Web and Engine
page_cat_n1 string "02_mallorca" Web
page_cat_n2 string "25_postals_vells" Web

With the new update, the acceptance status of cookies is recorded using the dataLayer through the gtm.consent event upon page load. If the user has not yet accepted cookies, all cookies will be marked as rejected except for the mandatory ones. If the user accepts the cookie policy or updates their consent, an update_consent event will be reported with the new cookie acceptance status.

Parameters Type Value (example) Platforms
functionality_storage string "granted" Web and Engine
ad_storage string "denied" Web and Engine
analytics_storage string "denied" Web and Engine

Generic Events

In the following table, we find the events implemented in the engine and on the web pages.

Event Description Informs that Platforms
generate_lead Reports a new subscription to the newsletter. When a user successfully submits the newsletter form. Web and Engine
sign_up* Reports the registration of a user on the platform. When a user successfully registers on the platform. Web and Engine
login* Reports the login of a user to the platform. When a user successfully logs in to the platform. Web and Engine
click_filter Reports applied filters in an accommodations search section. When filters are applied to accommodations search. Engine
view_search_result Reports the number of results or, if none, reports PAX distribution and hotel ID (or "all" in the search section). After an accommodations search. Engine
error Reports form errors that may appear on a page. When a validation or submission error occurs in a form. Web and Engine

* The sign_up and login events are not used because we don't have a customer area yet.

"Error" Event Codes

The following table displays the error codes assigned to each type of form.

error_id Description
1 Error in login form
2 Error in registration form
3 Error in password change form
4 Error in user profile form
5 Error in checkout form
6 Error in newsletter form
7 Error in contact form
8 Error in giveaway form
9 Error in job application form
10 Error in search mask form
11 Error in service reservation form (restaurant, spa, etc.)
12 Error in a custom form (if a form doesn't fit the above descriptions)

E-commerce Events

The following events have only been implemented in the engine and are ordered by their natural launch sequence. They are used to record user navigation, the purchase process, and conversions (purchase event).

Event Description Informs that: Platforms
view_item_list Reports a list of "items". When a list of accommodations or products is displayed on the screen. Engine
select_item Reports which "item" the user has selected. When the user clicks on a link to access the extended page of the "item." Engine
add_to_cart Reports the "item" added to the cart. When a user clicks to book an accommodation, package, etc. Engine
view_cart Reports the user's cart (list of "items"). When the user accesses the extras screen. Engine
begin_checkout Reports the user's cart (list of "items"). When the checkout process is initiated. Engine
add_shipping_info Reports the user's cart (list of "items"). When the user clicks "Continue with booking" after filling out the checkout form. Engine
add_payment_info Reports the chosen payment method during checkout and the list of "items" in the reservation. When a user reaches the reservation confirmation screen (my-booking). Engine
purchase Reports a conversion with transaction parameters and a list of "items". When the reservation is confirmed but the payment is not made through the engine or after the first payment of the reservation is made through the engine. Engine
refund Is triggered when a reservation is canceled. It is triggered automatically through GA4's Measurement Protocol. API

Event Type Parameter and Conversion Funnels

All e-commerce events include an event_type parameter that indicates
the stage the user is at or from which stage they initiated the booking for events reported during the checkout process (step-2, step-3, and my-booking). This parameter can be used to create specific conversion funnels for each section:

Section Value Description
search "booking_process/1-search-engine" This value is reported in events triggered in the "search" section.
search "booking_process/2-product-tariff" This value is reported in the "checkout" for bookings initiated from the "search" section.
step-1 "booking_process/2-product-hotel" It informs this value for events triggered in "step-1" and in "checkout" for bookings initiated from "step-1".
step-1 "hotelverse_process/2-product-hotel" This value is reported for bookings made through Hotelverse.
step-details "booking_process/2-product-room" It informs this value for events triggered in "step-details" and in "checkout" for bookings initiated from "step-details".
step-packdetails "booking_process/2-product-package" It informs this value for events triggered in "step-packdetails" and in "checkout" for bookings initiated from "step-packdetails".

Item Object in E-commerce Events

All e-commerce events contain at least one item in the items property (array), which can have the following properties. All parameters are of string type except for index and quantity, which are of integer type (whole number).

Propiedad Descripción Valor
item_id Concatenate the item's IDs, its parent's ID (hotel), and the IDs of the board and rate applied to the "item" using the separator "/".. Rooms and Villas: hotel/room/board/rate. Packages: hotel/room/board/package. Products: hotel/product. Extras: "(not set)".
item_name Concatenate the names of the item, its parent, and the names of the board and rate applied to the "item" using the separator "/". Rooms and Villas: hotel/room/board/rate. Packages: hotel/room/board/package. Products: hotel/product. Extras: "(not set)".
price Depending on the type of "item," it will report either price per night or price per unit. Rooms, Villas, and Packages: Price per night. Extras and Products: Price per unit.
item_brand Reports the name of the chain. chain_name
item_category First-level categorization of the item. “accommodations”, “extras” or “products”
item_category2 For rooms, villas, and packages: Reports the parent category of the accommodation. For products: Reports the product type. For extras: Reports the type of extra. Rooms, Villas, and Packages: "hotel" or "villa". Products: "withdate" or "undate". Extras: "stay", "day", "unit", "unitday", "person", "personday", or "personstay".
item_category3 For rooms, villas, and packages: Reports the people distribution for the reservation. For products: Name of the category they are grouped under in the view. Rooms, Villas, and Packages: 1) Reservations for 1 room: adults_children_infant. Example: "2_1_0". Reservations for multiple rooms: adults1-adultsN_children1-childrenN_infants1-infantsN. Example: "2-2_1-0_0-0". Products: category_name. Example: "spa", "restaurant", etc. Extras: "(not set)".
item_category4 Reports the check-in date. Rooms, Villas, and Packages: Date in YYYYMMDD format. Example: "20230512". Products: Date in YYYYMMDD format for date-based products. "(not set)" for products without a date. Extras: "(not set)".
item_category5 Concatenates the board and rate names with the separator "/". board/rate
item_variant Reports the item variant. Rooms and villas: “tariff”. Packages: “package”. Extras and products: “(not set)”.
item_list_name Reports the name of the list where the item is located or the name of the list from which the item's reservation is initiated. "default" for search engine results page (SERP), "map" for search with map view, "packages" for packages in room/villa details, "category" for products, "extras" for extras.
item_list_id Reports the stage the user is currently at or from which stage the reservation was initiated. Same values as the "event_type" parameter.
index Indicates the position of the item in the list. position. Example: 7.
quantity Rooms, Villas, and Packages: Reports the number of nights. Extras and Products: Reports the quantity of items. Rooms, Villas, and Packages: nights. Example: 5. Extras and Products: quantity. Example: 2.
coupon Reports the names of the applied offers to the item concatenated with "/". offer_1/offer_2/offer_n
discount Rooms, Villas, and Packages: Reports the discount per night. Extras and Products: Reports the discount per each unit of items. Rooms, Villas, and Packages: discount_per_night. Example: "25.00". Extras and Products: discount. Example: "5.00".

Custom Parameters of the Item Object

To enhance analytics, we use the custom parameters from the following table.

Property Description Value Type of item
item_hotel_name Reports the hotel name. hotel_name All
item_room_name* Reports the room or villa name. room_name or villa_name Room or villa
item_board_name* Reports the board name. board_name Room, villa or package
item_rate_name* Reports the rate name. rate_name Room or villa
item_package_name* Reports the package name. package_name Package
item_product_name* Reports the product name. product_name Product
item_extra_name* Reports the extra name. extra_name Extra

* We will only find these parameters if the item type matches the one defined in the table. For example, a product like 'Spa Entry' will have the parameters item_hotel_name and item_product_name, while a room or villa will have the parameters item_hotel_name, item_room_name, item_board_name, and item_rate_name.

Parameter 'option' of the purchase event

To distinguish whether the purchase event has been reported immediately after reaching the 'my-booking' section or reported after making a payment in this section (this depends on the payment method configuration), the option event parameter should be used. This can have two values:

  • "auto": the purchase event is reported upon reaching 'my-booking' with payment methods like 'Credit Card as Guarantee (Pay at the Hotel)', 'Bank Transfer', etc.
  • "manual": the purchase event is reported after making a payment from 'my-booking' with payment methods like Virtual POS, PayPal, etc.

Transaction parameters reported in the purchase event

When a conversion is made, in addition to the acquired items, the following transaction parameters are also reported:

Name Type Description
transaction_id string Booking identifier.
value string Total booking price (PVP)
tax string Taxes included in booking.
currency string Currency.
coupon string Applied global offers (the majority of offers are applied directly to the "item").
items Array de "item" List of acquired items.

Custom transaction parameters reported in the purchase event

The parameters in the following table have been added to enhance analytics.

Name Type Description
cart_id string Cart ID.
prepaid string Amount paid at the time of reporting the event.
payment_type string Payment method.
checkin_date string Check-in date.

Google Tag Manager

Configuration

Customers are provided with a master containing the necessary settings for the proper data transmission to GA4. This includes variables, tags, and triggers that can aid in the correct functioning of scripts loaded through GTM (Google Tag Manager).

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
IMPORTANT: Before creating new variables, tags, or triggers in GTM, we should review whether they are already created and if they have the desired functionality or parameter to avoid duplications.

Below is a table showcasing the most commonly used elements from the master:

Name Type Description
All DOM Ready Trigger It's triggered when the DOM has fully loaded.
Neobookings - booking engine Trigger It's triggered in the booking engine.
Neobookings - booking-hotel Trigger It's triggered in step 1 and product selection screens.
Neobookings - booking-package Trigger t's triggered on the package page.
Neobookings - booking-room Trigger It's triggered on the room page.
Neobookings - checkout Trigger It's triggered on the purchase process pages.
Neobookings - confirmation Trigger It's triggered on the reservation confirmation screens.
Neobookings - login Trigger It's triggered on the login pages.
Neobookings - register Trigger It's triggered on the registration pages.
Neobookings - search-result Trigger It's triggered on the search results pages.
Neobookings - user-area Trigger It's triggered on the user area pages.
Neobookings - web Trigger It's triggered on the client's website.
dl - page_type Variable It contains the page type.
dl - language Variable It contains the page language.
dl - page_cat_n1 Variable It contains the top-level category of the website.
dl - page_cat_n2 Variable It contains the second-level category of the website.
dl - ecommerce.transaction_id Variable It contains the booking ID.
dl - ecommerce.payment_type Variable It contains the payment method used in the booking process.
dl - ecommerce.value Variable It contains the total RPP (Retail Price Point) of the booking.
dl - ecommerce.tax Variable It contains the cost of booking taxes.
dl - ecommerce.currency Variable It contains the currency type of the booking.
dl - ecommerce.prepaid Variable It contains the amount paid at the time of making the booking.
dl - ecommerce.checkin_date Variable It contains the booking check-in date.
NeoAnalytics - page.category Variable It contains the page category.
Neobookings - rootDomain Variable It contains the main domain of the site.
Neobookings - webtype Variable It contains whether the viewed page belongs to the website or the booking engine.
Neobookings - neobookingsAnalytics Variable It contains the neobookingsAnalytics object.
NeobookingsAnalytics - hotel_id Variable It contains the hotel ID (hash).
NeobookingsAnalytics - hotel_name Variable It contains the hotel name.
NeobookingsAnalytics - reservation_nights Variable It contains the number of nights in the reservation.
Neobookings - set cookie OrigenAds Tag It manages information from metasearch engine sources.
Neobookings - NeoTracking Tag It manages data transmission for Neobookings' internal analytics.

How to collect data from the dataLayer variable

Most events add information to the dataLayer. To collect this information, you need to create a "Data Layer Variable" in GTM or use one that's already created.

To collect data from an event using a "Data Layer Variable," you'll need to specify the property's name in the "Data Layer Variable Name" field.

Example: If you want to collect the value of analytics cookies to know if they are accepted or rejected, you would enter the following in the "Data Layer Variable Name" field:

analytics_storage

If you want to collect a parameter from an ecommerce event, in the "Data Layer Variable Name" field, you should enter the following:

ecommerce.<property>

Example: If you want to collect the value of transaction_id from the ecommerce event "purchase," you would enter the following in the "Data Layer Variable Name" field:

ecommerce.transaction_id

How to collect data from the "neobookingsAnalytics" object

To retrieve the value of a property from this object using GTM, you need to create a "JavaScript Variable" or use one that's already created. In this example, let's say you want to collect the "origin" parameter from the "neobookingsAnalytics" object. To do this, you should enter the following in the "Variable Name" field:

neobookingsAnalytics.origin