電子郵件標記會使用電子郵件中的結構化資料。Gmail 支援 JSON-LD 和 微資料,您可以使用這兩種標記方式在電子郵件中標記資訊。這樣一來,Google 就能瞭解這些欄位,並為使用者提供相關搜尋結果、動作和資訊卡。舉例來說,如果電子郵件是關於活動預訂,您可能會想標註開始時間、地點、票數,以及所有其他定義預訂的資訊。
第一個標記
假設您負責向參與者寄送 Google I/O 2013 門票,並想在這些電子郵件中使用標記語意資訊。至少,支援單確認電子郵件應包含以下 HTML:
<html>
<body>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Order for: John Smith<br/>
Event: Google I/O 2013<br/>
When: May 15th 2013 8:30am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
Reservation number: IO12345<br/>
</p>
</body>
</html>
標記這封電子郵件非常簡單。電子郵件內文中的相關資訊可透過結構化表單,以支援格式之一的格式新增至電子郵件 HTML 的 body
內。以下程式碼區塊顯示標記電子郵件的外觀:
JSON-LD
<html>
<body>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EventReservation",
"reservationNumber": "IO12345",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "Event",
"name": "Google I/O 2013",
"startDate": "2013-05-15T08:30:00-08:00",
"location": {
"@type": "Place",
"name": "Moscone Center",
"address": {
"@type": "PostalAddress",
"streetAddress": "800 Howard St.",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94103",
"addressCountry": "US"
}
}
}
}
</script>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Reservation number: IO12345<br/>
Order for: John Smith<br/>
Event: Google I/O 2013<br/>
Start time: May 15th 2013 8:00am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
</p>
</body>
</html>
微資料
<html>
<body>
<div itemscope itemtype="http://schema.org/EventReservation">
<meta itemprop="reservationNumber" content="IO12345"/>
<div itemprop="underName" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="John Smith"/>
</div>
<div itemprop="reservationFor" itemscope itemtype="http://schema.org/Event">
<meta itemprop="name" content="Google I/O 2013"/>
<time itemprop="startDate" datetime="2013-05-15T08:30:00-08:00"/>
<div itemprop="location" itemscope itemtype="http://schema.org/Place">
<meta itemprop="name" content="Moscone Center"/>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<meta itemprop="streetAddress" content="800 Howard St."/>
<meta itemprop="addressLocality" content="San Francisco"/>
<meta itemprop="addressRegion" content="CA"/>
<meta itemprop="postalCode" content="94103"/>
<meta itemprop="addressCountry" content="US"/>
</div>
</div>
</div>
</div>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Reservation number: IO12345<br/>
Order for: John Smith<br/>
Event: Google I/O 2013<br/>
Start time: May 15th 2013 8:00am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
</p>
</body>
</html>
微資料 (內嵌)
<html>
<body>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p itemscope itemtype="http://schema.org/EventReservation">
BOOKING DETAILS<br/>
Reservation number: <span itemprop="reservationNumber">IO12345</span><br/>
Order for: <span itemprop="underName" itemscope itemtype="http://schema.org/Person">
<span itemprop="name">John Smith</span>
</span><br/>
<div itemprop="reservationFor" itemscope itemtype="http://schema.org/Event">
Event: <span itemprop="name">Google I/O 2013</span><br/>
<time itemprop="startDate" datetime="2013-05-15T08:30:00-08:00">Start time: May 15th 2013 8:00am PST</time><br/>
Venue: <span itemprop="location" itemscope itemtype="http://schema.org/Place">
<span itemprop="name">Moscone Center</span>
<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress">800 Howard St.</span>,
<span itemprop="addressLocality">San Francisco</span>,
<span itemprop="addressRegion">CA</span>,
<span itemprop="postalCode">94103</span>,
<span itemprop="addressCountry">US</span>
</span>
</span>
</div>
</p>
</body>
</html>
上述電子郵件包含定義活動預訂的必要資訊。您可以在電子郵件中標記其他資訊,藉此改善使用者體驗。舉例來說,FlightReservation
物件的 ticketToken
屬性可讓您新增可納入登機證資訊卡的條碼圖片,例如 QR code。
如要瞭解所有支援的類型及其屬性,請參閱參考指南。