Adding (subject line) actions to Gmail using Schemas

You ever see those buttons in Google email subject lines? I see them mostly on Amazon.com orders where there is a tracking button right in the subject line.

Here’s how it’s done, or at least a way to test it.

Keep in mind that this won’t work until you register the domain that the email is coming from.

Google tutorial –
https://developers.google.com/gmail/markup/apps-script-tutorial

You can go to
https://script.google.com and test it.

Code.gs

function testSchemas() {
  var htmlBody = HtmlService.createHtmlOutputFromFile('mail_template').getContent();

MailApp.sendEmail({
  to: Session.getActiveUser().getEmail(),
  subject: 'Testing Gmail action Schemas :',
  htmlBody: htmlBody,
});
}

mail_template.html

<html>
<head>
<script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "EmailMessage",
 "description": "Check this out",
 "action": {
   "@type": "ViewAction",
   "url": "http://google.com"
  }
}
</script>
</head>
<body>
<p>This a test for a Go-to action in Gmail.</p>
</body>
</html>

Here is another Google resource for testing scripts. http://gmail-actions.appspot.com/

It's only fair to share...Tweet about this on TwitterShare on FacebookEmail this to someoneShare on Google+
This entry was posted in Email Dev and tagged , , , , , , . Bookmark the permalink.