Variables and conditions

Hotel Ads and free booking links include links to landing pages where the users can book rooms. You can define how Google constructs the link to include all additional information about the user and their itinerary. For example, you can include information such as the hotel ID, language, currency codes, and check-in dates in the URL.

Overview

You define the landing page URL in the landing pages file. When the ad or free booking link is displayed, dynamic information in the URL is replaced with actual values. To add dynamic values to your landing page URLs, use the following syntax:

<URL>https://partner_url?param_id=(variable_name)</URL>

The following examples shows a URL that uses Google's variable names instead of actual hotel ID and itinerary:

Example 1

<URL>https://www.partnerdomain.com?hotelID=(PARTNER-HOTEL-ID)
  &amp;checkinDay=(CHECKINDAY)&amp;checkinMonth=(CHECKINMONTH)
  &amp;checkinYear=(CHECKINYEAR)&amp;nights=(LENGTH)
</URL>

Example 2

<URL>https://www.partnerdomain.com/hotel/(PARTNER-HOTEL-ID)
  &amp;checkinDay=(CHECKINDAY)&amp;checkinMonth=(CHECKINMONTH)
  &amp;checkinYear=(CHECKINYEAR)&amp;nights=(LENGTH)
</URL>

When the landing page link is constructed for search results page, Google replaces the variables with the actual values to ensure the URL includes the dynamic information. For example, if the user books a room for 6 nights starting on 5/23/2023 for hotel #42, Google renders the previous link as the following:

https://www.partnerdomain.com?hotelID=42&checkinDay=23&checkinMonth=05&checkinYear=2023&nights=6

Values that Google assigns to the variables in the query string depends on the corresponding data in your Hotel Price Feed, Hotel List Feed and user settings.

For example,the value of LENGTH variable is assigned to <Nights> element from the related itinerary's price feed. Similarly, the value of PARTNER-HOTEL-ID variable is defined in the <id> element from the Hotel List Feed that matched the user's search criteria.

Some variables are subsets of the price feed elements. For example, the CHECKINDAY, CHECKINMONTH, and CHECKINYEAR variables are extracted from the single <Checkin> element in the price feed. Other variables are calculated based on the user's locale and other client settings.

For more information about the sources of variable values, refer to Pricing overview and Hotel List.

URL variables

The following table describes the available variables that you can use to construct your landing page URL:

Variable Recommended/optional Description
ADVANCE-BOOKING-WINDOW Optional The number of advance booking days prior to check-in date in the hotel's timezone at the time of booking. For example, 36.
ALTERNATE-HOTEL-ID Recommended (if you have separate IDs to identify properties versus booking engines) An alternate identifier for your property. This attribute name is specified in your Hotel List Feed. Having separate IDs is useful if you need one property identifier for your feed information and another property identifier for your booking engine.
CAMPAIGN-ID Recommended The ID of the Google Ads campaign you'd like to associate with the URL. This is blank if the click is not associated to a Google Ads campaign.
CHECKINDAY Recommended The two-digit day defined in the <Checkin> element of the Hotel Price Feed. For example, 20.
CHECKINDAY-OF-WEEK Optional The day of the week —Monday to Sunday, when the check-in takes place, in the hotel's timezone. For example, Tuesday.
CHECKINMONTH Recommended The two-digit month defined in the <Checkin> element of the Hotel Price Feed. For example, 05.
CHECKINYEAR Recommended The four-digit year defined in the <Checkin> element of the Hotel Price Feed. For example, 2023.
CHECKOUTDAY Recommended The two-digit day calculated from the <Nights> and <Checkin> elements of the Hotel Price Feed. For example, 26.
CHECKOUTMONTH Recommended The two-digit month calculated from the <Nights> and <Checkin> elements of the Hotel Price Feed. For example, 05.
CHECKOUTYEAR Recommended The four-digit year calculated from the <Nights> and <Checkin> elements of the Hotel Price Feed. For example, 2023.
CHILD-AGE Recommended (must be provided for child occupancy pricing) The maximum age of each child as specified in the <Child "age"> elements of the price feed. This variable must be used in conjunction with a FOR-EACH-CHILD-AGE conditional block.
CHILD-INDEX Optional A 0-indexed loop variable representing a counter for each child occupant and child age specified in the itinerary. While it is not mandatory, this variable can only be used in conjunction with a FOR-EACH-CHILD-AGE conditional block.
CLICK-TYPE Optional Indicates whether the user clicked on the listing for a standard hotel rate or for a Room Bundle. Possible values are:
  • hotel: The user clicked on the listing for a standard room rate.
  • room: The user clicked on the listing for a Room Bundle.
CLOSE-RATE-RULE-IDS Optional (only applies if you are using conditional or private rates) A comma-separated list of rate rule IDs for rates that were unavailable, but it could have been available if the user had taken a minor action. Note that rate rule IDs for private rates are always be populated here when a corresponding UI treatment is shown to the user.
CUSTOM[1-5] Optional The values for custom fields defined in the <Result> element with 200 characters limit per custom field. For more information, refer to Overview of Transaction Messages. Custom fields are not available when using ARI.
DATE-TYPE Optional Indicates whether the user selected the default date or a specific date provided in the search. Possible values are:
  • default: The user clicked on a hotel ad or free booking link where the default dates were used.
  • selected: The user clicked on a hotel ad or free booking link with the dates set.
GOOGLE-ADS-CLICK-SOURCE Optional Indicates Google Ads was the source of the click. Possible values are:
  • bl: Paid Booking Links
  • tpa: Travel Promotions Ads
  • tfsa: Travel Feeds in Search Ads
  • pm: Performance Max or Performance Max for Travel Goals campaigns.
  • Note: If the click originated from Google Search rather than Google Ads, this parameter is empty

GOOGLE-SITE Optional The Google property on which a user viewed your hotel pricing data. Possible values are:
  • localuniversal: The user found the hotel booking link through google.com search.
  • mapresults: The user found the hotel booking link through maps.google.com.
  • verification: Google uses this value when performing automated data quality tests on your site. You are not billed for these queries. Google Analytics can use this parameter and its value for identifying Hotel Ads automated verification traffic.
  • unknown: The user found the ad or free booking link through an undetermined source.
LENGTH Recommended The length of stay in terms of the number of nights defined by the <Nights> element in the Hotel Price Feed. For example, 3.
NUM-ADULTS Recommended (must be used with the NUM-CHILDREN or FOR-EACH-CHILD-AGE condition) The number of adult occupants specified for the itinerary by the user. This variable must be used in conjunction with NUM-CHILDREN, FOR-EACH-CHILD-AGE, or both.
NUM-CHILDREN Recommended The number of child occupants (0-17 yrs old) specified in the itinerary by the user. NUM-CHILDREN, FOR-EACH-CHILD-AGE, or both are required to successfully participate in itineraries with child occupants.
NUM-GUESTS Recommended (if you don't send child occupancy pricing) The total number of occupants, both adults and children, specified for the itinerary by the user. This value is a sum of the NUM-ADULTS and NUM-CHILDREN values. To maximize participation, it is strongly recommended to utilize both NUM-ADULTS and NUM-CHILDREN instead.
PACKAGE-ID Recommended (applies if you use Room Bundles) The unique identifier for the package in the Hotel Price Feed. For a standard package, the package ID is the value of the <PackageID> element within a <Result> block. For a Room Bundle, the package ID is the value of the <PackageID> element within the <RoomBundle> or <PackageData> blocks of the Transaction message.
PARTNER-CURRENCY Optional The three-letter currency code defined by the <Baserate> element's currency attribute in the Hotel Price Feed. For example, USD or CAD .
PARTNER-HOTEL-ID Recommended The unique identifier for the hotel defined by the <id> element in the Hotel List Feed.
PARTNER-ROOM-ID Recommended (applies if you use Room Bundles) The unique identifier for the room in the Hotel Price Feed. For a standard room, the room ID is a value of the <RoomID> element within the <Result> block. For a Room Bundle, the room ID is the value assigned to the <RoomID> element within the <RoomBundle> or <RoomData> blocks in the Transaction message.
PAYMENT-ID Optional (only applies to Ads) Resolves to a predefined string commission, or Google's assigned IATA number (for example, "01234567"), if you use a commissions collection agency. To change the formatting of your IATA number or predefined string, contact your Technical Account Manager (TAM).
PRICE-DISPLAYED-TAX (Optional) The tax amount displayed to the user in the user's local currency. The value of PRICE-DISPLAYED-TAX is the value of the <Tax> element in the Hotel Price Feed. For example, "3.14".
PRICE-DISPLAYED-TOTAL (Optional) The total cost of the room that is displayed to the user in the user's local currency. The value of PRICE-DISPLAYED-TOTAL is the sum of the <Baserate>, <Tax>, and <OtherFees> elements from the Hotel Price Feed. For example, "152.13".
PROMO-CODE (Optional)

If you use ARI promotions, the value of this variable is assigned to the id attribute of the applied <Promotion>. If multiple promotions are applied, it is a comma-separated list of promotion IDs in an arbitrary order.

If you use rate rules, the value of this variable is assigned to the PromoCode element if the corresponding rate rule is applied.

RATE-PLAN-ID Recommended (only applies if you use RoomBundles) The ID as defined by the <RatePlanID> element in a price feed's <RoomBundle> block. The <RatePlanID> represents the unique identifier for a room and package data combination. For more information, see Room Bundles.
RATE-RULE-ID Recommended (only applies if you use conditional rates or private rates) The ID as defined by the rate_rule_id attribute within a price feed's <Rate> block. For more information, refer to Conditional Rates.

Note: Only conditional rates or private rates that are not hidden are shown.

USER-COUNTRY Recommended A two-letter country code that indicates the user location. This information is extracted from the user's client settings. For example, US or FR.
USER-CURRENCY Recommended A three-letter currency code that indicates the user's local currency. The value of the USER-CURRENCY variable is inferred from the user's client settings. For example, USD or CAD .
USER-DEVICE Recommended The user's device type. The value of USER-DEVICE can be one of the following:
  • mobile
  • tablet
  • desktop
  • unknown

The value of the USER-DEVICE variable is inferred from the user's client settings.

USER-LANGUAGE Recommended A two-letter ISO 639-1 language code that specifies the display language of the ad or free booking link. The value of the USER-LANGUAGE variable is inferred from the user's client settings. For example, en or fr.
USER-LIST-ID (defined in Google Ads) Optional (only applies if you use Audience Lists in Google Ads) The Google Ads user list ID that contains the audience list or user information. Audience lists are used as a basis for setting bid adjustments. If the user is part of multiple audience lists, the audience list with the largest bid adjustment is selected. Ties among audiences with the largest bid adjustment are decided randomly.
VERIFICATION Optional A boolean that verifies if the link was generated by Google for testing or automated validation. It is true if the link was generated by Google for testing or automated validation, otherwise it is false.

Conditional logic in URLs

You can use special directives in the <URL> element of a landing pages file to conditionally build endpoints.

The conditional logic supports the following statements:

  • if_statement: If true, then the values that follow this condition are inserted into the URL, otherwise the values following the ELSE directive are inserted.

  • for_statement: Creates a FOR loop condition that iterates on the number of values provided.

IF and FOR statements include the following:

Condition Recommended/optional Description
IF-AD-CLICK (Hotel Ads only) Optional Resolves to true if the user click originated from an ad. Resolves to false if the user click originated from a free booking link.
IF-CLICK-TYPE-HOTEL Optional Resolves to true if the user clicked on a listing for a hotel, otherwise resolves to false.
IF-CLICK-TYPE-ROOM Optional Resolves to true if the user clicked on a listing for a Room Bundle, otherwise resolves to false.
IF-CLOSE-RATE-RULE-IDS Optional Resolves to true if one or more conditional rates were unavailable because the user was ineligible, otherwise resolves to false. By default, it is trueif a private rate UI treatment was shown to the user.
IF-DEFAULT-RATE Optional Resolves to true if the user clicked on a hotel listing where default dates were used, otherwise resolves to false.
IF-HOTEL-CAMPAIGN Optional Resolves to true if the user click originated from a hotel campaign, otherwise resolves to false. This distinction is helpful for partners that have multiple campaign types present in Google Ads to allocate attribution.
IF-PAYMENT-ID (Hotel Ads only) Recommended (if you use pay-per-stay Google Ads campaigns) Resolves to true for hotels in the Pay-Per-Stay (PPS) commissions program otherwise resolves to false.
IF-PROMO-CODE Optional Resolves to true if the user clicked on a rate which is based on an ARI promotion or a rate rule with a given PromoCode; otherwise resolves to false.
IF-PROMOTED (Hotel Ads only) Recommended (if you use Promoted hotels) Resolves to true if the user clicked on a Property Promotion Ad, otherwise resolves to false.
IF-RATE-RULE-ID Optional Resolves to true if the user selected a conditional rate , otherwise resolves to false.
IF-USER-LIST-ID (defined in Google Ads) Optional Resolves to true if the user is a member of a Google Ads customer list ID you specified when setting bid multipliers for audience lists, otherwise resolves to false.
IF-VERIFICATION Optional Resolves to true if the link was generated by Google for testing or automated validation, otherwise resolves to false.
ELSE Recommended (if you use any conditional IF statements) If the previous condition is not met, then the values that follow this condition are inserted into the URL.
END-IF Optional (required if you have any IF conditional statements) Ends the IF statement conditional block.
FOR-EACH-CHILD-AGE Optional (required for child occupancy pricing) Executes one time for each <Child "age"> element in the price feed. For example, if the <OccupancyDetails> include the two elements <Child age="17"> and <Child age= "17">, then the directive executes two times.
END-FOR-EACH Optional (required if using FOR-EACH block) Ends the FOR-EACH statement conditional block.

IF-AD-CLICK example

You can construct a conditional block that checks if the user clicked an ad or free booking link to redirect to your landing page.

The following example uses this directive in a landing page file:

<URL>https://partner.com?hid=(PARTNER-HOTEL-ID)(IF-AD-CLICK)&amp;adType=1(ELSE)&amp;adType=0(ENDIF)</URL>

In this example, if the user did not click an ad, the result is the following URL:

https://www.partner.com?hid=123&adType=0

If the user clicked the ad, the result is the following URL:

https://www.partner.com?hid=123&adType=1

IF-CLICK-TYPE-HOTEL example

You can construct a conditional block that checks if the user selected a hotel without an explicit Room Bundle. The value of <RatePlanID> element in the <Room Bundle> block of a Transaction message will be set to the implicitly associated room bundle price that the user had selected.

The following example uses this directive in a landing pages file:

<URL>https://partner.com/(IF-CLICK-TYPE-HOTEL)landing(ELSE)landing_room(ENDIF)?hid=(PARTNER-HOTEL-ID)</URL>

In this example, if the user selected a Room Bundle, the result is the following URL:

https://partner.com/landing_room?hid=123

If the user didn't select a Room Bundle, the result is the following URL:

https://partner.com/landing?hid=123

IF-CLICK-TYPE-ROOM example

You can construct a conditional block that checks if the user selected a Room Bundle.

The following example uses this directive in a landing pages file:

<URL>https://partner.com/(IF-CLICK-TYPE-ROOM)landing_room(ELSE)landing(ENDIF)?hid=(PARTNER-HOTEL-ID)</URL>

In this example, if the user didn't select a Room Bundle, the result is the following URL:

https://partner.com/landing?hid=123

If the user selected a Room Bundle, the result is the following URL:

https://partner.com/landing_room?hid=123

IF-DEFAULT-DATE example

Use the IF-DEFAULT-DATE conditional statement to set a non-date parameter that your website can then use to trigger custom behavior if the user didn't select a date.

The following example checks if the default date was used:

<URL>https://partner.com?hotelID=(PARTNER-HOTEL-ID)&amp;checkinDay=(CHECKINDAY)&amp;checkinMonth=(CHECKINMONTH)&amp;checkinYear=(CHECKINYEAR)&amp;nights=(LENGTH)<strong>(IF-DEFAULT-DATE)</strong>&amp;popup_datepicker=true(ELSE)&amp;popup_datepicker=false(ENDIF)</URL>

In this example, if the user didn't select a date, the result might be similar to the following URL that shows default date selections:

https://partner.com?hotelID=123&checkinDay=23&checkinMonth=05&checkinYear=2023&nights=1&popup_datepicker=true

If the user selected a date, the result might be similar to the following URL, depending on the itinerary they selected:

https://partner.com?hotelID=123&checkinDay=23&checkinMonth=05&checkinYear=2023&nights=2&popup_datepicker=false

IF-HOTEL-CAMPAIGN example (Hotel ads and free booking links clicks)

You can construct a conditional block that checks if the user clicked an ad that originated from a hotel campaign.

The following example uses this directive in a landing page file:

<URL>https://partner.com?hotelID=(PARTNER-HOTEL-ID)(IF-HOTEL-CAMPAIGN)&amp;hotel_campaign=(CAMPAIGN-ID)(ELSE)utm_campaign=(CAMPAIGN-ID)(ENDIF)</URL>

In this example, if the user clicks on a hotel campaign URL, the result is the following URL:

https://www.partner.com?hotelID=123&hotel_campaign=12345678

If the click is not on a hotel campaign URL (e.g. regular search campaign), the result is the following URL:

https://www.partner.com?hotelID=123&utm_campaign=87654321

This is useful when you want to distinguish the traffic of hotel campaign clicks from any other clicks.

Blank CAMPAIGN-IDs with FBL clicks

If the click is from a free booking link, then IF-HOTEL-CAMPAIGN returns TRUE and CAMPAIGN-ID value is set to blank as shown in the following URL:

https://www.partner.com?hotelID=123&hotel_campaign=

You can use IF-AD-CLICK conditional statement to prevent blank campaign ID as shown in the following example:

<URL>https://partner.com?hotelID=(PARTNER-HOTEL-ID)(IF-HOTEL-CAMPAIGN)(IF-AD-CLICK)&amp;hotel_campaign=(CAMPAIGN-ID)(ELSE)&amp;FreeBookingLink(ENDIF)(ELSE)utm_campaign=(CAMPAIGN-ID)(ENDIF)</URL>

IF-PAYMENT-ID example (Hotel Ads only)

Use the IF-PAYMENT-ID conditional statement to vary the URL based on whether the click is a result of the PPS commissions program or not. The example below checks if a click came from the PPS commissions program and assigns a value to the booking_source parameter based on the result:

<URL>https://partner.com?hid=(PARTNER-HOTEL-ID)&amp;booking_source=(IF-PAYMENT-ID)(PAYMENT-ID)(ELSE)cpc(ENDIF)</URL>

If the hotel is part of the Commissions program, the result is one of the following URLs:

  • If no IATA number has been assigned to Google:
    https://partner.com?hid=123&amp;booking_source=commissions
  • If an IATA number has been assigned to Google:
    https://partner.com?hid=123&amp;booking_source=01234567

Otherwise, the result is the following URL:

https://partner.com?hid=123&booking_source=cpc

IF-PROMOTED example (Hotel Ads only)

You can construct a conditional block that checks if the user clicked on a Property Promotion Ad.

The following example uses this directive in a landing pages file:

<URL>https://partner.com/(IF-PROMOTED)1(ELSE)0(ENDIF)?hid=(PARTNER-HOTEL-ID)</URL>

In this example, if the user selected a Property Promotion Ad, the result is the following URL:

https://partner.com/1?hid=123

If the user didn't select a Property Promotion Ad, the result is the following URL:

https://partner.com/0?hid=123

IF-RATE-RULE-ID example

You can construct a conditional block that checks if the user selected a conditional rate and if that is the case then the value of the <RateRuleID> element in the <Rate> block of the transaction message is used.

The following example uses this directive in a landing pages file:

<URL>https://partner.com?hid=(PARTNER-HOTEL-ID)(IF-RATE-RULE-ID)&amp;customerType=42(ELSE)(ENDIF)</URL>

In this example, if the user did not select a conditional rate, the result is the following URL:

https://www.partner.com?hid=123

If the user selected a conditional rate, the result is the following URL:

https://www.partner.com?hid=123&customerType=42

IF-USER-LIST-ID example (defined in Google Ads)

If you set bid multipliers for audience lists in a hotel campaign in Google Ads, you can use IF-USER-LIST-ID in conjunction with USER-LIST-ID to set a parameter on your website for a customer who belongs to a certain Google Ads audience list. You may want to do so for tracking purposes or to customize your website for members of audience lists.

<URL>https://partner.com/?hid=(PARTNER-HOTEL-ID)(IF-USER-LIST-ID)&amp;audience_list=(USER-LIST-ID)(ELSE)(ENDIF)</URL>

In this example, if the user wasn't a member of an audience list, the result is the following URL:

https://www.partner.com?hid=123

If the user was a member of the audience list 12345678, the result is the following URL:

https://www.partner.com?hid=123&audience_list=12345678

IF-VERIFICATION example

If you need to check whether Google generated the URL for testing or automated validation, you can use IF-VERIFICATION.

<URL>https://partner.com/?hid=(PARTNER-HOTEL-ID)(IF-VERIFICATION)&amp;isgoogle=true(ENDIF)</URL>

In this example, if Google didn't generate the URL for testing or validation, the result is the following URL:

https://www.partner.com?hid=123

If Google generated the URL for testing or validation, the result is the following URL:

https://www.partner.com?hid=123&isgoogle=true

FOR-EACH-CHILD-AGE example

You can construct a conditional block that populates the maximum age of each child occupant, as specified in the Hotel Price Feed.

The following example uses this directive in a landing pages file:

<URL>https://partner.com?adults=(NUM-ADULTS)&amp;children=(NUM-CHILDREN)(FOR-EACH-CHILD-AGE)&amp;age=(CHILD-INDEX)_(CHILD-AGE)(END-FOR-EACH)&amp;hid=(PARTNER-HOTEL-ID)&amp;</URL>

In this example, if the itinerary had 2 adults and 2 children with ages 0 and 17 respectively, the result is the following URL:

https://www.partner.com?adults=2&children=2&age=0_0age=1_17&hid=123

If the itinerary had 2 adults and 0 children then the result is the following URL:

https://www.partner.com?adults=2&children=0&hid=123

General rules when building URLs

All variables are optional. You are not required to insert any variables in your landing page URL. However, using variables to pass itinerary and user information generally creates a better experience for the user and aids you in conforming to Google's policies.

The following general rules apply when defining constructed URLs in a landing pages file:

  • All variables are surrounded with open and close parentheses.

  • Query string parameters must be separated by an ampersand ("&") in the final output. Because the ampersand is a special character in XML and the landing pages file format is XML. Therefore, you must use the encoded entity "&amp;" in its place. The final output renders an actual "&" character. For example:

    <!-- Do this: -->
    <URL>https://www.partnerdomain.com?hotelID=(PARTNER-HOTEL-ID)&amp;nights=(LENGTH)</URL>
    
    <!-- Do NOT do this: -->
    <URL>https://www.partnerdomain.com?hotelID=(PARTNER-HOTEL-ID)&nights=(LENGTH)</URL>
    

    You must also URL-encode special characters that you might include in the landing page URL. For example:

    • space (" "): Replace space characters with "%20;" in the <URL> element
    • forward slash ("/"): Replace forward slashes with "%2F;" in the <URL> element

    Not all non-alphabetical characters must be URL encoded. For example, hyphens ("-") doesn't need to be URL encoded. For a list of common characters that must be URL encoded, consult URL Encoding.

  • Values for a single parameter can be constructed from multiple variables. The following example constructs a single parameter, checkinDate, from the CHECKINDAY,CHECKINMONTH, and CHECKINYEAR variables:

    <URL>https://www.partnerdomain.com?checkinDate=(CHECKINDAY)%2F;(CHECKINMONTH)%2F;(CHECKINYEAR)</URL>
    

    This example results in a URL that might look like the following:

    https://www.partnerdomain.com?checkinDate=7/23/1971
    
  • You can use any ID for the name of the query string parameters. Your server processes these values. However, the values that you pass are limited to the list of available variables.

  • You can use up to five custom variables in addition to the list of available variables.