添加LodgingReservation类型Json-LD标记后无添加到日历弹窗问题
Gmail中LodgingReservation标记不触发日历添加的问题解决
问题背景
我按Google Gmail标记指南,通过Gmail SMTP自发送邮件测试schema.org的Json-LD标记,使用的LodgingReservation示例代码如下:
<script type="application/ld+json"> { "type" : "LodgingReservation", "checkinTime" : "2025-24-01T15:00:00Z", "checkoutTime" : "2025-24-05T11:00:00Z", "potentialAction" : { "type" : "ReserveAction", "name" : "Add to calender", "target" : "https://calendar.google.com" }, "reservationFor" : { "type" : "LodgingBusiness", "address" : { "type" : "PostalAddress", "addressCountry" : "Sample Country", "addressLocality" : "Sample City", "addressRegion" : "Sample State", "postalCode" : "12345", "streetAddress" : "123 Sample Street" }, "name" : "Sample Hotel Chain", "telephone" : "+1234567890" }, "reservationId" : "123456789", "reservationStatus" : "http://schema.org/ReservationConfirmed", "underName" : { "type" : "Person", "name" : "John Doe" }, "@context" : "http://schema.org" } </script>
需求是让该预订触发添加到日历的弹窗或自动添加,但测试后无效果。已做尝试:Schema验证工具验证通过、调整potentialAction、改用microdata格式、使用Google官方示例在结构化数据测试工具验证、Node.js Nodemailer测试,均无效。
核心修复步骤
1. 修正日期格式错误
你的checkinTime和checkoutTime格式完全错误,schema.org要求日期遵循YYYY-MM-DD格式,你写的2025-24-01是月份为24,属于无效值,Gmail无法解析。修正为:
checkinTime": "2025-01-24T15:00:00Z"checkoutTime": "2025-05-24T11:00:00Z"
2. 移除错误的potentialAction配置
Gmail对于预订类标记,会自动生成「添加到日历」按钮,不需要手动指定potentialAction,且你用的ReserveAction类型错误,正确触发日历操作的类型是AddAction,但更建议直接移除该字段,让Gmail自动处理。
3. 解决域名信任问题
Gmail对未验证域名发送的邮件会忽略结构化标记,个人Gmail账号自发送的邮件属于此类。建议:
- 使用已配置SPF/DKIM/DMARC的域名发送测试邮件
- 不要用同一个Gmail账号自发送,换另一个Gmail账号接收
4. 确保标记放置正确
将Json-LD标记放在邮件HTML正文的<body>标签最顶部,不要放在隐藏元素内,确保没有被CSS样式隐藏。
修复后的完整示例代码
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "LodgingReservation", "reservationId": "123456789", "reservationStatus": "https://schema.org/ReservationConfirmed", "underName": { "@type": "Person", "name": "John Doe" }, "reservationFor": { "@type": "LodgingBusiness", "name": "Sample Hotel Chain", "telephone": "+1234567890", "address": { "@type": "PostalAddress", "streetAddress": "123 Sample Street", "addressLocality": "Sample City", "addressRegion": "Sample State", "postalCode": "12345", "addressCountry": "Sample Country" } }, "checkinTime": "2025-01-24T15:00:00Z", "checkoutTime": "2025-05-24T11:00:00Z" } </script>
额外测试建议
- 检查邮件是否被标记为垃圾邮件,垃圾邮件中的结构化标记不会被解析
- 确保邮件HTML格式无语法错误,比如标签闭合完整
- 使用Google官方的结构化数据测试工具再次验证修正后的标记
内容的提问来源于stack exchange,提问作者Anish Karthik
相关产品推荐
相关产品推荐

