酒店价格:启用抓取工具导航和价格标记

本指南概述了如何使用微数据和导航属性为您的网站添加代码,以便 Google 的价格准确性抓取工具可以自动浏览您的预订漏斗并验证您的房价。


概念性抓取工具流程

以下序列展示了抓取工具如何浏览典型的预订漏斗、处理动态加载状态并识别关键操作。

🗺️ 快速流程概览

  • 🔗 第 1 阶段:Google 平台 - 抓取工具访问动态着陆页网址(由 Google 根据您的模板配置),像真实用户一样进入您的网站。
  • 🛬 第 2 阶段:着陆页 - 抓取工具到达合作伙伴网站 (data-nav-stage="landing")。
  • 🖱️ 第 3 阶段:导航 - 抓取工具执行使用 data-nav-* 属性声明的强制性互动(点击)。
  • 🏁 第 4 阶段:最终页面 - 抓取工具到达最终可访问的页面 (data-nav-stage-final="true")。
  • 📊 第 5 阶段:价格提取 - 抓取工具提取带有微数据标记的价格,并验证住宿总费用。

第 1 步:着陆页(酒店选择或可选的追加销售页面)

抓取工具会访问着陆页网址(用户点击 Google 商品后在合作伙伴网站上到达的页面)。如需详细了解如何配置着陆页参数以确保选择正确的费率,请参阅变量和条件。

状态 A:加载屏幕

加载指示器遮罩会短暂显示。抓取工具会等待此导航标记消失(最长 30 秒)。

<body data-nav-stage="landing">
  <!-- Loading indicator: crawler waits for this to disappear (max 30 seconds) -->
  <div data-nav-loading-indicator="true">Loading Page...</div>
</body>

状态 B:网页已加载

加载指示器消失后,页面内容即加载完毕。抓取工具会找到并点击关键路径元素以继续。

<body data-nav-stage="landing">
  <!-- Ignored: Crawler skips non-selected rates -->
  <div class="hotel-result">
    <h3>Grand Hotel - Basic Room</h3>
    <button>View Rates</button>
  </div>

  <!-- critical path: crawler clicks this to advance -->
  <div class="hotel-result selected-rate">
    <h3>Grand Hotel - Deluxe Suite</h3>
    <button data-nav-criticalpath="true"
            data-nav-interactiontype="CLICK"
            data-nav-interactionorder="1">
      View Rates
    </button>
  </div>
</body>

第 2 步:可选的中间页面(客房或选项选择)

抓取工具到达费率选择页面。

状态 A:加载屏幕

在提取费率时,系统会显示一个旋转图标。

<body data-nav-stage="room-selection">
  <div data-nav-loading-indicator="true">Fetching Rates...</div>
</body>

状态 B:网页已加载

加载完成后,抓取工具可能会先依次与多个元素互动,然后再继续。只有强制性互动(例如,同意强制性条款或根据用户在 Google 上的选择或最低强制性价格路径选择所需配置)才应添加标记。

<body data-nav-stage="room-selection">
  <!-- Step 1: mandatory interaction (e.g., select bed configuration) -->
  <div class="rate-option">
    <p>Deluxe Suite</p>

    <!-- Note: Either the value selected by the user on Google should be pre-selected,
         or navigation elements must be provided so the crawler can select it. -->
    <div class="bed-selection">
      <button data-nav-criticalpath="true"
              data-nav-interactiontype="CLICK"
              data-nav-interactionorder="1">
        Select Queen Bed
      </button>
      <button>Select King Bed</button>
    </div>
  </div>

  <!-- Step 2: mandatory interaction (e.g., mandatory insurance opt-out or agreement) -->
  <div class="mandatory-notice">
    <label>
      <input type="checkbox"
             data-nav-criticalpath="true"
             data-nav-interactiontype="CLICK"
             data-nav-interactionorder="2">
      I agree to the non-refundable dynamic pricing waiver.
    </label>
  </div>

  <!-- Step 3: Continue to checkout -->
  <button data-nav-criticalpath="true"
          data-nav-interactiontype="CLICK"
          data-nav-interactionorder="3">
    Continue Reserving
  </button>
</body>

第 3 步:最终抓取页面(价格验证/预订摘要)

抓取工具会到达最终可访问的页面(用户输入个人信息或付款信息之前的最终页面)。它会验证 data-nav-stage-final 标志是否为 true。这会指示抓取工具在完成所有剩余导航后提取带有微数据标记的价格。在提取价格之前,系统始终会先与导航标记进行互动。

主要项范围应为酒店和 LodgingReservation 的共类型(例如 itemtype="https://schema.org/Hotel https://schema.org/LodgingReservation")。为了向后兼容,我们也接受父级 Hotel 范围,其中包含共类型为 Offer 和 LodgingReservation 的子元素(例如 <div itemprop="makesOffer" itemscope itemtype="https://schema.org/Offer https://schema.org/LodgingReservation">)。页面上应仅标记该 Hotel 下的一个 Hotel 和 Offer。

  • 此示例仅显示强制性总价标记,为简单起见,建议使用此标记。{Simple total price}

    <!-- End of Scope comments identify container boundaries -->
    <body data-nav-stage="checkout" data-nav-stage-final="true">
    
      <!-- Booking Summary Cart Scope (Hotel + LodgingReservation) -->
      <div class="booking-summary" itemscope itemtype="https://schema.org/Hotel https://schema.org/LodgingReservation">
    
        <!-- Hotel Identifier (Can be hidden meta tag) -->
        <meta itemprop="identifier" content="grand-hotel-001" />
    
        <h2 itemprop="name">Grand Hotel</h2>
    
        <!-- Visible Stay Dates & Occupancy (checkinDate / checkoutDate are also acceptable) -->
        <p>
          Check-in: <span itemprop="checkinTime" content="2026-08-10">Aug 10, 2026</span> |
          Check-out: <span itemprop="checkoutTime" content="2026-08-15">Aug 15, 2026</span> |
          Guests: <span itemprop="numAdults">2</span> Adults, <span itemprop="numChildren">1</span> Child
        </p>
    
        <!-- Offer Scope -->
        <div class="cart-details" itemprop="makesOffer" itemscope itemtype="https://schema.org/Offer">
    
          <!-- Compound Price Scope -->
          <div itemprop="priceSpecification" itemscope itemtype="https://schema.org/CompoundPriceSpecification">
    
            <div class="total-line">
              <span>Total Stay (Taxes Included):</span>
              <!-- The crawler extracts this final rate as total price -->
              <span itemprop="price">440.00</span>
              <meta itemprop="priceCurrency" content="USD" />
            </div>
    
          </div> <!-- End of CompoundPriceSpecification Scope -->
        </div> <!-- End of Offer Scope -->
      </div> <!-- End of Hotel/LodgingReservation Scope -->
    
    </body>
    
  • 此示例显示了总价以及明细(基本费率和费用)。{Total price and breakdown}

    <!-- End of Scope comments identify container boundaries -->
    <body data-nav-stage="checkout" data-nav-stage-final="true">
    
      <!-- Booking Summary Cart Scope (Hotel + LodgingReservation) -->
      <div class="booking-summary" itemscope itemtype="https://schema.org/Hotel https://schema.org/LodgingReservation">
    
        <!-- Hotel Identifier (Can be hidden meta tag) -->
        <meta itemprop="identifier" content="grand-hotel-001" />
    
        <h2 itemprop="name">Grand Hotel</h2>
    
        <!-- Visible Stay Dates & Occupancy (checkinDate / checkoutDate are also acceptable) -->
        <p>
          Check-in: <span itemprop="checkinTime" content="2026-08-10">Aug 10, 2026</span> |
          Check-out: <span itemprop="checkoutTime" content="2026-08-15">Aug 15, 2026</span> |
          Guests: <span itemprop="numAdults">2</span> Adults, <span itemprop="numChildren">1</span> Child
        </p>
    
        <!-- Offer Scope -->
        <div class="cart-details" itemprop="makesOffer" itemscope itemtype="https://schema.org/Offer">
    
          <!-- Compound Price Scope -->
          <div itemprop="priceSpecification" itemscope itemtype="https://schema.org/CompoundPriceSpecification">
    
            <!-- Unit price scope for base rate -->
            <div class="line-item" itemprop="priceComponent" itemscope itemtype="https://schema.org/UnitPriceSpecification">
              <span itemprop="name">Base Rate</span> (5 Nights):
              <span itemprop="price">400.00</span>
              <meta itemprop="priceCurrency" content="USD" />
            </div> <!-- End of UnitPriceSpecification Scope -->
    
            <!-- Unit price scope for fee -->
            <div class="line-item" itemprop="priceComponent" itemscope itemtype="https://schema.org/UnitPriceSpecification">
              <span itemprop="name">Resort Fee</span>:
              <meta itemprop="priceComponentType" content="ResortFee" />
              <span itemprop="price">40.00</span>
              <meta itemprop="priceCurrency" content="USD" />
            </div> <!-- End of UnitPriceSpecification Scope -->
    
            <div class="total-line">
              <span>Total Stay:</span>
              <!-- The crawler extracts this final rate as total price -->
              <span itemprop="price">440.00</span>
              <meta itemprop="priceCurrency" content="USD" />
            </div>
    
          </div> <!-- End of CompoundPriceSpecification Scope -->
        </div> <!-- End of Offer Scope -->
      </div> <!-- End of Hotel/LodgingReservation Scope -->
    
    </body>
    

使用自定义 data-nav-* HTML 属性来注释互动元素并声明漏斗阶段,以便抓取工具可以遍历您的预订流程。

1.1 首页顶部阶段声明 (data-nav-stage)

预订漏斗中显示费率的每个页面都应声明其阶段,并附加到 <body> 标记或主要封装容器标记(例如 <div>、<section> 或 <main>)。这会告知抓取工具预订流程的哪个阶段处于活跃状态,并有助于日后排查问题。

  • data-nav-stage(推荐):声明活跃的漏斗阶段。虽然并非严格要求,但指定名称(例如 "landing"、"room-selection"、"checkout"、"ready-for-payment")有助于在验证期间识别活跃阶段。

1.2 最终阶段指示器 (data-nav-stage-final)

在用户输入个人信息或付款信息之前显示价格的最终页面上,将最终阶段标志与阶段声明(例如 data-nav-stage="ready-for-payment")一起添加到页面顶部的容器中。

  • data-nav-stage-final(价格验证页面必需):在抓取工具可以访问的预订漏斗的最终页面上设置为 "true" (data-nav-stage-final="true")。这表示在完成所有必要的导航步骤后,抓取工具应从此页面读取价格。请勿将 data-nav-criticalpath="true" 放置在此页面上的最终付款提交按钮上。如果您的预订漏斗有条件地跳过中间步骤(例如,在不适用时跳过可选的加购内容页面),则该路径中个人或付款输入之前的最后一步页面必须包含 data-nav-stage-final="true" 和价格结构化数据。

1.3 关键路径互动属性

在中间页面上,标记可引导用户沿着预订关键路径前进的互动元素(按钮或链接)。如果需要在同一页面上执行多项操作,请指定执行顺序。抓取工具会按照指定的顺序执行操作,然后尝试在最终页面上提取价格。

属性 必填值 用途
data-nav-criticalpath "true" 标记抓取工具必须点击才能继续的强制性按钮/链接。
data-nav-interactiontype "CLICK" 声明互动操作。 CLICK 适用于按钮/链接。
data-nav-interactionorder "1"、"2"… 如果需要在同一页面上执行多项操作,则声明执行顺序。
data-nav-loading-indicator "true" 标记表示加载状态的元素(例如旋转图标)。抓取工具会等待此元素消失,然后再继续。

最小导航示例

<button data-nav-criticalpath="true"
        data-nav-interactiontype="CLICK"
        data-nav-interactionorder="1">
  Continue
</button>

2. 价格声明(微数据)

在预订漏斗的最终可访问页面上(在输入个人信息或付款信息之前),使用微数据标记为价格优惠(一项价格优惠)添加标记。页面上应仅标记一个优惠,指明抓取工具提取的房价,该房价应与用户在进入您的网站之前在 Google 上选择的房价一致。如需详细了解如何定义着陆页参数,请参阅变量和条件。

虽然 Google 完全支持酒店价格结构化数据参考中的完整层次结构(包括分项基础房价、各项税费、其他费用和客房详情),但 Google 也接受简化的结构化数据树,以便您更轻松地在网页上标记酒店价格。

对于可预订的房价,必须提供总住宿价格(包括所有强制性税费,甚至包括在酒店收取的强制性费用,但不包括可选的加购项)。税费明细 (UnitPriceSpecification) 和 HotelRoom 标记是可选的。如果行程或房源不可用或已售罄(包括直接在初始着陆页上显示),请设置不含 data-nav-criticalpath="true" 元素的 data-nav-stage-final="true",并在 makesOffer 下声明 https://schema.org/SoldOut(使用 <meta itemprop="availability" content="https://schema.org/SoldOut"/> 或 <link itemprop="availability" href="https://schema.org/SoldOut"/>),但不含 priceSpecification:

<div itemprop="makesOffer" itemscope itemtype="https://schema.org/Offer">
  <meta itemprop="availability" content="https://schema.org/SoldOut"/>
  Sold Out
</div>

如需了解详情,请参阅 availability 属性规范。

2.1 简化的结构化数据树

为了简化预约页面上的代码植入,您只需声明根酒店和预订容器、住宿日期 (YYYY-MM-DD)、总预订入住人数(numAdults 和 numChildren),以及包含总入住价格的单个优惠:

Hotel / LodgingReservation (Root Container)
├── identifier                   [Meta/Attribute] Hotel ID
├── name                         [Visible text] Hotel Name
├── checkinTime / checkoutTime   [Visible text with YYYY-MM-DD in content="..."] Stay Dates
├── numAdults / numChildren      [Visible text] Total Reservation Occupancy
└── makesOffer (Offer)
    └── priceSpecification (CompoundPriceSpecification)
        ├── priceCurrency        [ISO Code, such as "USD"] Currency
        └── price                [Visible text] Total Stay Price (Taxes & Fees Included)

2.2 关键可见性规则

为确保可靠地提取价格,请在标记 HTML 时遵循以下可见性规则:

  • 总住宿价格必须仅封装可见数字:仅将可见价格数字本身封装在 <span itemprop="price"> 内(将货币符号和额外文本(例如 <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price">1,250.00</span>)保留在 span 之外)。逗号和点号小数或千位格式(1,250.00 或 1.250,00)都会自动解析。请勿在隐藏的自适应摘要抽屉式导航栏中使用隐藏的元数据 (<meta>)、属性值(value="..." 或 content="...")或重复的 itemprop="price" 元素。
  • 机器可读的住宿日期:尽可能在网页上标记可见的住宿日期。在 <span> 或 <time> 元素上显示人类可读的日期时,请添加 content="YYYY-MM-DD"(例如 <span itemprop="checkinTime" content="2026-08-10">August 10, 2026</span>;checkinDate 也可以接受)。请勿仅依赖 HTML5 datetime="..." 属性,抓取工具会忽略该属性。
  • 避免将文本属性直接放置在 <a href="..."> 链接上:请勿将 itemprop="name" 等文本属性直接放置在具有 href 属性的 <a> 标记上,因为这会提取链接网址,而不是可见文本。而是应将可见文本封装在 <a> 元素内的 <span itemprop="name"> 中。
  • 不可见字段:不直接显示在页面上的字段(例如酒店 ID 或 3 字母 ISO 货币代码)可以使用 <meta> 标记或 content="..." 属性。

3. 示例

以下端到端示例展示了如何使用导航属性和微数据为中间漏斗步骤和最终结账页添加标记。

示例 1:包含可点击按钮的中间页

以下代码段展示了一个中间房间选择页面 (room-selection),其中包含一个标记为推进流程的关键路径操作按钮:

<body data-nav-stage="room-selection">
  <!-- Main page content -->
  <button class="btn-continue"
          data-nav-criticalpath="true"
          data-nav-interactiontype="CLICK"
          data-nav-interactionorder="1">
    Book This Room
  </button>
  <!-- Rest of the Main page content -->
</body>

示例 2:包含阶段指示器和最少微数据的最终价格页面

以下代码段展示了付款前的最后一个页面 (ready-for-payment),其中 data-nav-stage-final="true" 在封装容器上声明,并且权威入住价格会明显显示:

<body data-nav-stage="ready-for-payment" data-nav-stage-final="true">

  <!-- Root Container: Co-Typed Hotel & LodgingReservation -->
  <div itemscope itemtype="https://schema.org/Hotel https://schema.org/LodgingReservation">

    <!-- Hotel Identifier (Can be hidden meta tag) -->
    <meta itemprop="identifier" content="grand-view-001" />
    <h1 itemprop="name">Grand View Hotel</h1>

    <!-- Visible Stay Dates & Occupancy -->
    <p>
      Check-in: <span itemprop="checkinTime" content="2026-08-10">Aug 10, 2026</span> |
      Check-out: <span itemprop="checkoutTime" content="2026-08-15">Aug 15, 2026</span> |
      Guests: <span itemprop="numAdults">2</span> Adults, <span itemprop="numChildren">1</span> Child
    </p>

    <!-- Single Minimal Rate Offer -->
    <div itemprop="makesOffer" itemscope itemtype="https://schema.org/Offer">
      <div itemprop="priceSpecification" itemscope itemtype="https://schema.org/CompoundPriceSpecification">

        <p class="summary-total">
          Total Stay Price (Taxes & Fees Included):

          <!-- 3-letter ISO Currency Code (can use content="" for hiding the 3-letter currency code while displaying a symbol) -->
          <span itemprop="priceCurrency" content="EUR">€</span>

          <!-- VISIBLE TOTAL STAY PRICE (Directly wrapped, no hidden attributes) -->
          <span itemprop="price">650.00</span>
        </p>

      </div>
    </div>

  </div>

</body>

4. 验证您的实现

在部署更改之前,请测试您的标记和导航标记,以确保抓取工具可以成功验证您的价格数据。

4.1 验证价格和微数据结构

您可以使用 Schema.org 验证器或 Google 富媒体搜索结果测试来检查从网页网址或 HTML 内容中提取的微数据。根据酒店价格结构化数据参考文档中的规范验证提取的字段,并确保 itemprop="price" 元素是网页上的可见项。

4.2 验证导航

如需验证代码,请在 Google Chrome 中打开浏览器开发者工具,方法是右键点击网页并选择检查(或按 F12)以检查 HTML DOM。查找具有 data-nav-* 属性的元素。

确认您的实现符合以下导航要求:

  • 声明了页首阶段:预订流程中的每个页面都在其 <body> 或根封装容器标记中包含 data-nav-stage="...",最终价格页面包含 data-nav-stage-final="true"。
  • 关键路径已完成:中间页面的互动元素(按钮或链接)已标记为 data-nav-criticalpath="true"、data-nav-interactiontype 和 data-nav-interactionorder。如果存在多项操作,请确保正确设置订单号。

4.3 验证可见性和标记质量

确认您的微数据满足所有结构和可见性要求(如需了解详情,请参阅简化的结构化数据树和关键可见性规则):

  • 严格的层次结构:确保您的标记遵循所需的 DOM 嵌套顺序(简化树或完整的结构化数据参考规范)。不支持标准 HTML itemref 属性,并且抓取工具可能会漏掉顺序不正确或嵌套不当的元素。
  • 可见价格:itemprop="price" 仅直接封装可见价格数字(将货币符号保留在外部,支持英文逗号和英文句点数字格式),不含隐藏属性(content="..." 或 value="...")或 <meta> 标记。
  • 机器可读的住宿日期:checkinTime 和 checkoutTime(或 checkinDate 和 checkoutDate 属性)包含标准 YYYY-MM-DD 日期格式(在显示人类可读的日期时,使用 content="YYYY-MM-DD",而不是仅使用 HTML5 datetime="...")。如果使用完整时间戳(例如 2027-08-21T23:59:59),则仅提取前导 YYYY-MM-DD 日期部分。
  • 直接元素标记:所有可见属性(酒店名称、住宿日期、总预订入住人数)都会封装可见的网页文本(并且不会将文本属性(例如 itemprop="name")直接放置在 <a href="..."> 标记上)。