Use the global site tag for vacation packages conversion tracking

Conversion tracking informs you of the rate at which users convert (buy products and services) on your website after clicking through to your booking page from vacation packages.

Sites that list vacation packages on Google can set up conversion tracking through integration with Google’s global site tag (gtag). Use this article to learn how to set up the global site tag for vacation packages.

Note: If you are currently using the 1x1 pixel image snippet to track conversions, you should plan to switch to the global site tag as soon as possible. The previous method depends on third-party cookies, which can be blocked by modern browsers. The global site tag ensures that all of your conversions are accounted for.

How it works

Conversion tracking with gtag relies on first-party cookies set on your domain. Conversion IDs are passed between Google-owned domains and customer-owned domains via URL parameters.

In order to set a cookie on your domain, you need to add JavaScript that executes in a first-party context on your site pages. Ideally, these scripts are placed on all pages of your site, but minimally they must be present on all possible landing pages.

Before you begin

Have your vacation packages partner ID ready. You’ll need write access to the files on your site, as well as permission to make JavaScript calls.

Implement conversion tracking

To implement conversion tracking, you first add the global tracking snippet to all pages on your site, then add the gtag() function to your booking confirmation page(s) to capture the details of any purchase and send this information to Google.

Note: Please ensure you're providing users with clear and comprehensive information about the data you collect on your websites, and getting consent for that collection where legally required. If you have not obtained users’ consent for the collection, sharing, and use of personal data for personalization of ads where legally required, be sure to disable the collection of remarketing data. Learn how to modify the global site tag to disable the collection of remarketing data for specific users.

1. Add the global tracking snippet

Add the global tracking snippet, gtag.js, in the <head> element on every page of your site. The only parameter you need for this is your vacation packages partner ID.

 

<!-- Global Site Tag (gtag.js) - Vacation packages Search -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GP-${partner-id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());

gtag('config', 'GP-${partner-id}');
</script>

Google generates a unique event ID for the user click, and encodes the encrypted event ID and partner ID as parameters on your landing pages: partner.com/landing.html?gclid=eventId&gclsrc=gp

2. Enable bookings to send conversion information

The event tag needs to be placed on your booking confirmation page. Place the gtag() function inside a function which handles button clicks:

gtag('event', eventName, eventParams);

Where:

  • eventName is ‘purchase’
  • eventParams is a structure that describes the package purchase details, including pricing, passenger, hotel, and flight information as shown below.
gtag('event', 'purchase', {
'send_to': 'GP-<partner-id>',
'value': total_price,
'currency': currency,
'passengers':
{ // passenger info
total: passenger_count,
adult: adult_count,
child: child_count,
infant_in_seat: infant_in_seat_count,
infant_in_lap: infant_in_lap_count
} ,
'items': [
{ // hotel info
'id': 'partner_hotel_id',
'start_date': hotel_checkin_date,
'end_date': hotel_checkout_date,
},
{ // first segment
'travel_class': cabin,
'fare_product': fare_product,
'booking_code': booking_code,
'flight_number': flight_number,
'origin': origin_airport,
'destination': destination_airport,
'start_date': departure_date,
},
{ // next segment
'travel_class': cabin,
'fare_product': fare_product,
'booking_code': booking_code,
'flight_number': flight_number,
'origin': origin_airport,
'destination': destination_airport,
'start_date': departure_date,
}
]
});

Replace the field values with your site-specific values. The following table describes the fields:

Field name Field value Required? Description
send_to partner-id Required The unique vacation packages partner identifier, a number.
value total_price Required The total cost of the package, including all fees and taxes, a number. Commas cannot be used as decimal separators; use a period instead, for example “3289.99”.
currency currency Required The currency in which the value is measured, in ISO 4217 format. For example, “EUR”.
passengers     The fields that pertain to the passengers.
passengers.total passenger_count Required The total number of passengers on the flight, a number; for example, “2”. Several passenger types are supported.
passengers.adult adult_count Optional The total number of adults on the flight.
passengers.child child_count Optional The total number of children on the flight.
passengers.infant_in
_seat
infant_in_seat
_count
Optional The total number of infants in seats on the flight.
passengers.infant_in
_lap
infant_in_lap
_count
Optional The total number of infants without seats on the flight.

items[0] (hotel details)

    The fields that pertain to the hotel details.
items[0].id partner_hotel_id Required The ID of the hotel being booked. This is the unique ID that you use in your Hotel List Feed.
items[0].start_date hotel_checkin_date Required The check-in date for the hotel, in YYYY-MM-DD format. For example, “2016-10-24”.
items[0].end_date hotel_checkout_date Required The check-out date for the hotel, in YYYY-MM-DD format. For example, “2016-10-30”.
items[0].end_date return_date Required The date of the return flight, in YYYY-MM-DD format. For example, “2016-10-31”.

items[1+] (segment details)

    The fields that pertain to each flight segment.
items[1+].travel_class cabin Optional The cabin class name. Typical cabin names include "ECONOMY", "PREMECO", "BUSINESS", and "FIRST".
items[1+].fare_product fare_product Optional The fare product (also known as brand) associated with the flight segment. For example, “Basic Economy”, “Premium Flex”, and “Economy Saver”.
items[1+].booking_code booking_code Optional A comma-separated list of booking codes, where each code is a 1-letter reservation booking code per segment. If there is more than one booking code, do not add spaces between each value. For example, “X,Y”.
items[1+].flight_number flight_number Optional The flight number, in the format XXnnn, where XX is the 2-letter carrier code and nnn is the flight number.
items[1+].origin origin_airport Required The 3-letter code for the origin airport. For example, “BOS”.
items[1+].destination destination_airport Required The 3-letter code for the destination airport. For example, “LAX”.
items[1+].start_date departure_date Required The date of the outbound segment in YYYY-MM-DD format. For example, “2020-11-03”.

Full request sample

This example represents a sample data layer value for a round trip between Boston and Zürich (2 segments). Use gtag() to populate the values.

gtag('event', 'purchase', {
'send_to': 'GP-<partner_id>',
'value': '1180.00',
'currency': 'USD',
'passengers': {
total: 2,
adult: 2,
child: 0,
infant_in_seat: 0,
infant_in_lap: 0
} ,
'items': [
{
'id': '12345_partner_hotel_id',
'start_date': '2020-04-17',
'end_date': '2020-04-21',
},
{
'travel_class': 'Economy',
'fare_product': 'Basic Economy',
'booking_code': 'U',
'flight_number': 'LX53',
'origin': 'BOS',
'destination': 'ZRH',
'start_date': '2020-04-17',
},
{
'travel_class': 'Economy',
'fare_product': 'Basic Economy',
'booking_code': 'U',
'flight_number': 'UA53',
'origin': 'ZRH',
'destination': 'BOS',
'start_date': '2020-04-21',
}
]
})
Was this helpful?
How can we improve it?