Conditional rates are a type of rate rule that lets you offer different rates
for itineraries, based on criteria such as the user's device, country, or
whether the user has signed in to Google.

When you have more than one public or conditional rate for an itinerary or
Room Bundle, the user will see the lowest rate. Google always picks the lowest
eligible rate for the user.

## Overview

Conditional rates are visible in the standard pricing slots, and are shown only
to users whose searches meet the criteria for the associated conditional rate.
These criteria can be based on the following:

- [End-user device](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#device)
- [End-user country](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#country)
- [End-user language preference](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#userlang)
- [Downsampled subset of all users](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#downsampled)
- [Whether the end-user is signed in](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#signed)

To enable conditional rates, modify the following:

- [Rate rules XML file](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#defn):
  Define the conditions in which the conditional rates are applied.

- [Price feed](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#price): Use the
  `<Rate>` element in a Transaction message to set the rates.

- [Landing Page file](https://developers.google.com/hotels/hotel-prices/dev-guide/fenced-rates#pos): Add
  rate rule specific values to your deep links.

### Device-specific conditional rates

Device-specific rates are hotel rates that are only visible and bookable by
users on a specific device such as a mobile, tablet, or desktop. The rates are
provided by Google's partners, and end-users can see and book the same
device-specific rates on the partner's site.

![fenced_rates](https://developers.google.com/static/hotels/images/fenced-rates.png)

### Country-specific conditional rates

Country-specific rates are hotel rates that are only visible and bookable
by users who are searching for hotels from a specific country. Google
determines the country using the end-user's IP address. The rates are provided
by Google's partners, and end-users can see and book the same country-specific
rates on the partner's own country-specific site.

### Language-specific conditional rates

Language-specific rates are visible only to users who are searching for hotels
while utilizing a specific language setting in Google. Language-specific
conditions are defined using the `<LanguageCode>` element.

Language isn't specified in [With Context queries](https://developers.google.com/hotels/hotel-prices/dev-guide/query-messages#with_context_queries)
request messages. So, if you specify `<LanguageCode>` in your rate rules, then
the With Context response should include all relevant language-specific
rates.

> [!IMPORTANT]
> **Important:** If you are uncertain, it is recommended that you use country conditions instead of language conditions for determining user origin or nationality. However, if you have rates which are specific to the primary language of the user, then use language conditions.

### Downsampled conditional rates

Downsampled conditional rates are visible only to a randomized subset of all
eligible users. The sampling rate is defined using the `<MaxUsersPercent>`
element and calculated using the following:

    MaxUsersPercent = (number of users selected to view rate)/(total eligible users)

### Signed-in conditional rates

Signed-in rates are visible only to users who have signed in with a Google
Account. Google's partners provide the rates, and users can view and book
the rates on the partner's own site. Signed-in rates are defined using the
`<UserSignedIn>` element.

> [!IMPORTANT]
> **Key Point:** The [Price Accuracy Policy](https://support.google.com/hotelprices/answer/6064419) ensures that the search result rates and the rates that appear after click-through match during booking.

Since Google always selects the lowest eligible rate, if a conditional rate
is higher than the price set at the [`<Result>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#Result) level, the conditional rate
will *never* be selected. To avoid this, [remove the
rate](https://developers.google.com/hotels/hotel-prices/dev-guide/removing-inventory) at the [`<Result>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#Result)
level and condition all rates. Alternatively, ask your Technical Account Manager
about using a default rate rule for prices set at the [`<Result>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#Result) level.

## Create a rate rules XML file

Rate rules for conditional rates are defined using a rate rules XML file. For
more information, see the [Rate Rules XML
Reference](https://developers.google.com/hotels/hotel-prices/xml-reference/rate-rules).

## Update your price feed

Conditional rates are set using the element in a
[Transaction message](https://developers.google.com/hotels/hotel-prices/dev-guide/transaction-overview).

The `<Rate>` element can also be used as multiple child elements of [`<Rates>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#Rates)
within the [`<RoomBundle>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#RoomBundle) or [`<Result>`](https://developers.google.com/hotels/hotel-prices/xml-reference/transaction-messages#Result) elements. To use it as a conditional
rate, you must set the value of the `rate_rule_id` attribute to match with
the rate rule ID that you defined in the rate rules XML file.

If you don't have a default public double occupancy rate, set the `<Baserate>`
child element of the `<Result>` message to `-1`. Any conditional
`<Rates>` that are sent to Google in this case will be considered valid.

### Examples

### Base + conditional

The following example shows a Transaction message that contains a **base
rate and a conditional rate**:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Transaction timestamp="2023-05-18T16:20:00-04:00" id="42">
      <Result>
        <Property>1234</Property>
        <Checkin>2023-04-10</Checkin>
        <Nights>1</Nights>

        <Baserate currency="USD">200.00</Baserate>
        <Tax currency="USD">20.00</Tax>
        <OtherFees currency="USD">1.00</OtherFees>

        <Rates>
          <!-- The rate_rule_id is required when using conditional rates -->
          <Rate rate_rule_id="mobile">
            <!-- Override base rate and taxes for conditional rates -->
            <Baserate currency="USD">180.00</Baserate>
            <Tax currency="USD">18.00</Tax>
          </Rate>
        </Rates>

      </Result>
    </Transaction>

### RoomBundle single

The following example shows a Transaction message that contains **a single
rate under a `<RoomBundle>`**:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Transaction timestamp="2023-05-18T16:20:00-04:00" id="42">
      <Result>
        <Property>1234</Property>
        <Checkin>2023-04-10</Checkin>
        <Nights>2</Nights>

        <Baserate currency="USD">300.00</Baserate>
        <Tax currency="USD">30.00</Tax>
        <OtherFees currency="USD">2.00</OtherFees>

        <RoomBundle>
          <RoomID>single</RoomID>
          <Baserate currency="USD">300.00</Baserate>
          <Tax currency="USD">30.00</Tax>
          <OtherFees currency="USD">2.00</OtherFees>
        </RoomBundle>

        <RoomBundle>
          <RoomID>3</RoomID>  <!-- Links to data in metadata -->
          <RatePlanID>basic</RatePlanID>
          <Baserate currency="USD">275.00</Baserate>
          <Tax currency="USD">27.50</Tax>
          <ChargeCurrency>web</ChargeCurrency>
          <BreakfastIncluded>1</BreakfastIncluded>

          <Rates>
            <Rate rate_rule_id="mobile">
              <Baserate currency="USD">269.00</Baserate>
              <Tax currency="USD">2.69</Tax>
              <OtherFees currency="USD">1.00</OtherFees>
            </Rates>
          </Rates>

        </RoomBundle>
      </Result>
    </Transaction>

### RoomBundle multiple

The following example shows a Transaction message that contains **multiple
rates under a `<RoomBundle>`**:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Transaction timestamp="2023-05-18T16:20:00-04:00" id="42">
      <Result>
        <Property>1234</Property>
        <Checkin>2023-04-10</Checkin>
        <Nights>2</Nights>
        <!-- When Google receives new room bundle information for an itinerary, all
        previous room bundle pricing is dropped from Google's cache. Thus, if you
        want to delete a specific room bundle from Google's cache, you may do so
        by simply not providing that specific room bundle in subsequent transaction
        messages. -->
        <RoomBundle>
         ...
          <!-- RoomID is required, PackageID is recommended. -->
          <RoomID>5</RoomID>
          <PackageID>ABC</PackageID>
          <!-- Baserate is required. -->
          <Baserate currency="USD">275.00</Baserate>
          <Tax currency="USD">27.50</Tax>
          <OtherFees currency="USD">2.00</OtherFees>

          <!-- RatePlanID is optional and represents the unique identifier for a
          room and package data combination. We strongly recommend using RatePlanID
          as a variable to build your dynamic landing page (formerly Point of Sale)
          URL and it should be within 50 characters in length for optimal
          performance. For details, see Using Variables and Conditions. -->
          <RatePlanID>5-ABC</RatePlanID>

          <!-- Occupancy is mandatory for RoomBundle elements. -->
          <!-- Elements below will get inherited to nested rate elements. -->
          <Occupancy>2</Occupancy>
          <OccupancyDetails>
            <NumAdults>2</NumAdults>
          </OccupancyDetails>
          <InternetIncluded>1</InternetIncluded>

          <!-- Rate rule "mobile" overrides chargeCurrency, "us_or_gb" doesn't. -->
          <ChargeCurrency>web</ChargeCurrency>

          <Rates>
            <Rate rate_rule_id="mobile">
              <Baserate currency="USD">258.33</Baserate>
              <Tax currency="USD">25.83</Tax>
              <OtherFees currency="USD">1.00</OtherFees>
              <!-- The value below overrides ChargeCurrency from roombundle. -->
              <ChargeCurrency>hotel</ChargeCurrency>
            </Rate>
            <Rate rate_rule_id="us_or_gb">
              <Baserate currency="USD">268.33</Baserate>
              <Tax currency="USD">26.83</Tax>
              <OtherFees currency="USD">1.00</OtherFees>
            </Rate>
          </Rates>
        </RoomBundle>
      </Result>
    </Transaction>

### No public double occupancy

The following example shows a Transaction message that contains
**conditional rate with no public double occupancy rate**:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Transaction timestamp="2023-05-18T16:20:00-04:00" id="42">

      <Result>
        <Property>1234</Property>
        <Checkin>2023-04-10</Checkin>
        <Nights>1</Nights>

        <!-- <Unavailable/> should not be specified when available nested rates
        exist. -->
        <Baserate currency="USD">-1</Baserate>
        <Tax currency="USD">0</Tax>
        <OtherFees currency="USD">0</OtherFees>

        <Rates>
          <!-- The rate_rule_id is required when using conditional rates. -->
          <Rate rate_rule_id="mobile">
            <Baserate currency="USD">180.00</Baserate>
            <Tax currency="USD">18.00</Tax>
            <OtherFees currency="USD">1.00</OtherFees>
            <Custom1>ratecode123</Custom1>
          </Rate>
        </Rates>

      </Result>
    </Transaction>

## Update your landing page file

To ensure that eligible end-users can book the discounted rate through a deep
link, modify your [Landing Page
file](https://developers.google.com/hotels/hotel-prices/dev-guide/pos-syntax). Additional implementation
might also be needed on the booking website to properly show and fulfill the
discounted rates.

We expect partners to honor the price shown at the conditional rate deep link.

In a dynamic deep link, you can include the rate rule by its name, the
`id` attribute of the `<RateRule>` element, with the `RATE-RULE-ID` variable.

The following example adds the rate rule ID:

    https://bookingsite.com/landing.do?id=(PARTNER-HOTEL-ID)&arrival=(CHECKINDAY)-(CHECKINMONTH)-(CHECKINYEAR)&departure=(CHECKOUTDAY)-(CHECKOUTMONTH)-(CHECKOUTYEAR)&lang=(USER-LANGUAGE)&currency=(USER-CURRENCY)\&prid=(RATE-RULE-ID)

The Landing Page file also supports the `IF-RATE-RULE-ID` directive that lets
you conditionally define parts of the URL, based on whether the rate rule
exists:

    https://bookingsite.com/(IF-RATE-RULE-ID)privatelanding.do(RATE-RULE-ID)(ELSE)landing.do(ENDIF)?id=(PARTNER-HOTEL-ID)&arrival=(CHECKINDAY)-(CHECKINMONTH)-(CHECKINYEAR)&departure=(CHECKOUTDAY)-(CHECKOUTMONTH)-(CHECKOUTYEAR)&lang=(USER-LANGUAGE)&currency=(USER-CURRENCY)

This example chooses between two landing pages, depending on whether the rate
rule ID is set.

For more information, see [Using Variables and
Conditions](https://developers.google.com/hotels/hotel-prices/dev-guide/pos-urls).