How to Implement Google Actions and Highlights - MailerSend

How to enable Google Email Actions & Highlights

Google Email Actions and Highlights allow you to add structured data to make your emails more interactive and visually engaging in the inbox.

The Actions and Highlights enable you to add a CTA (Call-To-Action) alongside a message in the inbox, or highlight important information from your email content, displaying them as easy-to-see ‘chips’ above the email, in the inbox preview, search results, or the Happening soon section.

This means you can place quick-access buttons for confirming a subscription, tracking a package, leaving a review, and many more. Or highlight flight information, restaurant reservation details, and other important information from the main email message.

How to add Google Email Actions and Highlights to your emails

Enabling Actions and Highlights involves adding a script snippet to your email body and getting approval from Google.

To do this, you’ll need to meet Google’s requirements and complete a registration form. Here’s what that looks like:

Step 1: Ensure you follow the registration guidelines for Email Sender Quality

Before you register with Google, you need to make sure that you comply with the following:

Note:

Gmail only checks the SPF of the domain of your Return-Path email. If you only rely on SPF, the domain of your Return-Path email must match the domain of your From email.

Step 2: Add the markup/schema to your email

For the Actions and Highlights to work, your email must contain schema markup that Gmail can parse the data from.

Note:

Google accepts either JSON-LD or Microdata to add the markup to your emails. However, if you are using MailerSend templates, you will only be able to use Microdata as the templates do not allow JSON scripts. If you won’t be using MailerSend templates and want to use JSON-LD, you can find examples in Google’s documentation.

How to add the snippet to an email

There are 2 ways to add the schema markup to your email:

1. In your API call

Simply add the snippet into the HTML of your API call, for example:

import 'dotenv/config';
import {
    MailerSend,
    EmailParams,
    Sender,
    Recipient
} from "mailersend";

const mailerSend = new MailerSend({
    apiKey: process.env.API_KEY,
});

const sentFrom = new Sender("bob@yourbusiness.com", "Bob");

const recipients = [\
    new Recipient("pam@theoffice.com", "Pam")\
];

const htmlContent = `
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
    <meta itemprop="name" content="Confirm Email Address"/>
    <div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
      <link itemprop="url" href="https://myemail.com/confirm?verifyId=abc123"/>
    </div>
  </div>
  <meta itemprop="description" content="Confirm email address for new account creation"/>
</div>
  <p>Hey there!</p>
  <p>Welcome to Your Business, we're happy to have you here!</p>
  <p>Please confirm your email address by clicking <a href=”https://myemail.com/confirm?verifyId=abc123”>here</a>.</p>
  <p>Remember to check out our guides and contact support if you need anything.</p>
  <br>
  <p>Regards,</p>
  <p>The Your Business Team</p>
`;

const emailParams = new EmailParams()
    .setFrom(sentFrom)
    .setTo(recipients)
    .setReplyTo(sentFrom)
    .setSubject("Welcome! Your free trial is ready.")
    .setHtml(htmlContent)
    .setText("Hey there! Welcome to Your Business, we're happy to have you here! Please confirm your email address by clicking here.Remember to check out our guides and contact support if you need anything. Regards, The Your Business Team");

mailerSend.email.send(emailParams)
    .then(response => {
        console.log("Email sent successfully:", response);
    })
    .catch(error => {
        console.error("Error sending email:", error);
    })

2. To a template

Drop the snippet into your template using one of the builders.

For the Drag & drop and Rich-text builders:

a) Select the main body block of your template and toggle to HTML.

b) Paste in the snippet and click Save.

For the HTML builder:

Simply paste the snippet anywhere in the section of your code.

Here’s a basic Microdata example for a One-Click Action to confirm an email address:

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
    <meta itemprop="name" content="Confirm Email Address"/>
    <div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
      <link itemprop="url" href="https://myemail.com/confirm?verifyId=abc123"/>
    </div>
  </div>
  <meta itemprop="description" content="Confirm email address for new account creation"/>
</div>

And here’s another example for adding a flight reservation highlight:

<div itemscope itemtype="http://schema.org/FlightReservation">
  <meta itemprop="reservationNumber" content="RXJ34P"/>
  <link itemprop="reservationStatus" href="http://schema.org/Confirmed"/>
  <div itemprop="underName" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Eva Green"/>
  </div>
  <div itemprop="reservationFor" itemscope itemtype="http://schema.org/Flight">
    <meta itemprop="flightNumber" content="110"/>
    <div itemprop="airline" itemscope itemtype="http://schema.org/Airline">
      <meta itemprop="name" content="United"/>
      <meta itemprop="iataCode" content="UA"/>
    </div>
    <div itemprop="departureAirport" itemscope itemtype="http://schema.org/Airport">
      <meta itemprop="name" content="San Francisco Airport"/>
      <meta itemprop="iataCode" content="SFO"/>
    </div>
    <meta itemprop="departureTime" content="2027-03-04T20:15:00-08:00"/>
    <div itemprop="arrivalAirport" itemscope itemtype="http://schema.org/Airport">
      <meta itemprop="name" content="John F. Kennedy International Airport"/>
      <meta itemprop="iataCode" content="JFK"/>
    </div>
    <meta itemprop="arrivalTime" content="2027-03-05T06:30:00-05:00"/>
  </div>
</div>

Check out Google’s reference to see all of the supported markup types and their properties.

Step 3: Send an email from your production servers

So that Google can check that you comply with their registration guidelines, you’ll need to send them an email for review. This step should be completed before you submit the registration form.

Note:

Step 4: Register with Google

Once you’re sure that you comply with Google’s guidelines and you’ve sent an email for review, you can fill out the registration form. Google will get back to you to update you on the status of your approval. They might also request further information to proceed with your application.

Note:

You’ll need to submit the form once per email address and/or action.

Structured data/Markup types

In the registration form, you’ll need to select the structured data types that you plan to add to your emails.

Types of Actions

You’ll also need to select the type of Action you intend to use, if any. Consider carefully the best action for your use case for the best chances of approval.

Bearer Identity Tokens

The registration form also asks if your action handler requires bearer identity tokens. These are needed if your server needs to verify the identity of the user (for example, if a user clicks ‘Manage booking’ in Gmail, you’ll need to confirm it's the person or email address to whom the booking belongs).

By default, Bearer Identity Tokens are not enabled. So, if you need Google to automatically send a token to verify the user, you’ll need to select ‘Yes’ and then configure the functionality to verify the requests coming from Google. Google recommends that you use the open-source Google API Client Library to verify Bearer tokens.

If the token generated by Google doesn’t verify, the service will respond to the request with 401 (Unauthorized).

Generate your own tokens

If you prefer not to have bearer tokens generated by Google, you can also generate your own time-limited, single-use tokens and embed them in your Action URLs.

When you’re sure you have everything configured correctly and you have accurately filled in the registration form, you can submit your request.

Need more info?

Feel free to reach out to support@mailersend.com. A member of our support team will gladly assist you.