הצהרה על פעולות

פעולה ב-schema.org מייצגת פועל או פעילות שאפשר לבצע על חלק מהנתונים המובְנים. יש תמיכה בכמה סוגים של פעולות, ואפשר להגדיר את כולם עם נתונים מובְנים דומים.

מעבר לפעולות

אם אתם מוסיפים תגי עיצוב לתוכן שלכם באמצעות ישויות של schema.org, תוכלו להוסיף עבורן פעולות 'מעבר אל'. לדוגמה, כדי שלישות EmailMessage יהיה קישור מעבר אל ViewAction, צריך לאכלס את הנכס potentialAction של האימייל כמו בדוגמה הבאה:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ViewAction",
    "target": "https://watch-movies.com/watch?movieId=abc123",
    "name": "Watch movie"
  },
  "description": "Watch the 'Avengers' movie online"
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="target" href="https://watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="name" content="Watch movie"/>
  </div>
  <meta itemprop="description" content="Watch the 'Avengers' movie online"/>
</div>

הערה: תוכנות אימייל אחרות שאינן תומכות בסכימות בהודעות אימייל, מתעלמות באופן אוטומטי מתגי העיצוב שלמעלה.

קישורי עומק לנייד

אפשר גם לקשר ישירות אל תוכן באפליקציות נייטיב לנייד ב-Android וב-iOS. כדי ליצור קישור עומק לאפליקציה, צריך לכלול כתובות URL נוספות מסוג target שמקודדות באמצעות הסכימות android-app:// ו-ios-app://, כפי שמוצג בהמשך:

JSON-LD

"target": [
  “<web url>”,
  “android-app://<android package name>/<scheme>/<host>/<path+query>”,
  “ios-app://<App store ID>/<scheme>/<host><path+query>"
]

מיקרו נתונים

<link itemprop="target" href="<web url>"/>
<link itemprop="target" href="android-app://<android package name>/<scheme>/<host>/<path+query>”/>
<link itemprop="target" href="ios-app://<App store ID>/<scheme>/<host>/<path+query>"/>

הרחבת הדוגמה הקודמת מ-EmailMessage:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "name": "Watch movie",
  ... information about the movie ...
  "potentialAction": {
    "@type": "ViewAction",
    "target": [
      "https://watch-movies.com/watch?movieId=abc123",
      "android-app://com.watchmovies.app/http/watch-movies.com/watch?movieId=abc123",
      "ios-app://12345/movieapp/watch-movies.com/watch?movieId=abc123"
    ]
  }
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <meta itemprop="name" content="Watch movie"/>
  ... information about the movie ...
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
    <meta itemprop="target" content="https://watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="target" content="android-app://com.watchmovies.android/http/watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="target" content="ios://12345/movieapp/watch-movies.com/watch?movieId=abc123"/>
 </div>
</div>

אם האפליקציה לא מותקנת אצל המשתמש, הפעולה תעביר אותו לכתובת ה-URL שסיפקתם.

פעולות בתוך האפליקציה

פעולות בתוך האפליקציה מטופלות במקום, בתוך Gmail, בלי לשלוח את המשתמש לאתר אחר. פעולות בתוך האפליקציה מוצהרות כמו פעולות של מעבר אל, אך הן כוללות מידע נוסף שמקל על סוכנים משתמשים (כגון Gmail) לטפל בפעולה המוטבעת.

במקום להצהיר על פעולה באמצעות target, צריך להצהיר על HttpActionHandler עבור הפעולה עם ההגדרות המתאימות.

לדוגמה, אפשר להוסיף לחצן אישור להודעות אימייל שבהן המשתמשים מתבקשים לאשר, לאשר ולאשר משהו. אחרי שהמשתמש ילחץ על הלחצן, תישלח בקשת HTTP מ-Google לשירות שלכם, שמתעד את האישור. אפשר לבצע אינטראקציה עם ConfirmAction רק פעם אחת.

בדוגמה הבאה מוסיפים לחצן ConfirmAction לאימייל לגבי דוח הוצאות:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ConfirmAction",
    "name": "Approve Expense",
    "handler": {
      "@type": "HttpActionHandler",
      "url": "https://myexpenses.com/approve?expenseId=abc123"
    }
  },
  "description": "Approval request for John's $10.13 expense for office supplies"
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
    <meta itemprop="name" content="Approve Expense"/>
    <div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
      <link itemprop="url" href="https://myexpenses.com/approve?expenseId=abc123"/>
    </div>
  </div>
  <meta itemprop="description" content="Approval request for John's $10.13 expense for office supplies"/>
</div>

פעולות שהתוקף שלהן עומד לפוג

במקרים רבים, הפעולות רלוונטיות רק לפרק זמן מוגבל. התוקף של פעולות שמשויכות לישויות עם תאריכים ידועים, כמו הזמנות של נסיעות, יפוג באופן אוטומטי. Gmail לא מציג את הפעולה לאחר סיום הנסיעה.

ניתן גם להוסיף זמני תפוגה לפעולות. לדוגמה: יכול להיות שפעולה של מימוש שובר או שמירת קוד מבצע תקפה לזמן מוגבל בלבד. כדי להגדיר את חלון הזמן שבו פעולה מסוימת מוצגת, מגדירים את המאפיינים startTime ו-endTime של הפעולה:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ConfirmAction",
    "name": "Save coupon",
    "handler":  {
       "@type": "HttpActionHandler",
       "url": "https://my-coupons.com/approve?couponId=abc123"
    },
    "startTime": "2015-06-01T12:00:00Z",
    "endTime": "2015-06-05T12:00:00Z"
  }
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
    <meta itemprop="name" content="Save coupon"/>
    <div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
      <link itemprop="url" href="https://my-coupons.com/approve?couponId=abc123"/>
    </div>
    <meta itemprop="startTime" content="2015-06-01T12:00:00Z" />
    <meta itemprop="endTime" content="2015-06-05T12:00:00Z" />
  </div>
</div>

קריאה נוספת

פרטים נוספים על פעולות זמינים במאמרים הבאים: