Gmail Actions

Gmail Actions allow web developers to embed call to action buttons directly into a Gmail user’s inbox, right on an email’s subject line.

The vast majority of web applications send some form of email notification, with larger and more complex web applications having a long list of the various email notifications they send to users and admins. Often these emails require or encourage their recipients to complete an action, for example clicking on a link to confirm their email address or to view a record.

Gmail Actions allow web developers to surface these actions right on the subject line in the inbox at Gmail. Just like Google’s rich snippets and structured data the recommended approach to accomplish this uses JSON-LD and utilises schemas from schema.org.

Sadly Gmail Actions aren’t available to all as there are a number of requirements that must be met prior to being able to register with Google for the privilege. Email senders must be sending an email volume in excess of 100 emails per day to Gmail recipients for several consecutive weeks along with authenticating emails with either DKIM or SPF, which should be the case anyway.

At the time of writing Gmail supports three Gmail Actions:

  • RSVP Actions for events

    • RsvpAction - For emails where recipients can RSVP with either “yes”, “no” or “maybe”.

  • One-click Actions for just about anything that can be performed with a single click

    • ConfirmAction - For emails requiring recipients to approve, confirm and acknowledge something. A ConfirmAction can only be interacted with once.

    • SaveAction - For emails where recipients can save a voucher or adding songs to the listen queue. A SaveAction can only be interacted with once.

  • Go-to Actions for more complex interactions

    • ViewAction - For emails requiring recipients to go to your site to complete the action.

    • TrackAction - For emails requiring recipients to go to your site to track packages being delivered.

A Go-to Action in an email will display a button as shown below in the recipient's Gmail inbox:

Gmail Actions

To accomplish this we need to include some JSON-LD code within the email the recipient is sent, Gmail detects this code, which is invisible to the recipient and outputs the necessary action button.

The following JSON-LD code is for the ViewAction that outputs a “Watch movie” button:

<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>

The following JSON-LD code is for a ConfirmAction that outputs an “Approve Expense” button, this is a One-click Action, which as you have no doubt guessed can only be interacted with once:

<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>

Google have recently (July 2017) deprecated the ReviewAction and within Google’s own documentation they mention more than once that the schemas from schema.org that these Gmail Actions are based upon are still being standardised and therefore are likely to change so the on-going maintenance of Gmail Actions should be consider with any implementation.

Gmail Actions provide a useful way for web developers to make emails more actionable and encourage recipients to complete the actions we want them to with greater ease. Despite being called Gmail Action, these also work in Google’s Inbox also.

There’s more information and code samples available on Google’s Gmail Actions documentation. Google also provide a useful Email Markup Tester to check your JSON-LD code is valid.

You might also like...

Why Hosting Matters

Dan Walsh by Dan Walsh