Search code examples
htmlgmailhtml-email

How to create a custom button in a tooltip when hovering over an email in Gmail


enter image description here

GitLab for example has this fancy View merge request button and Unsubscribe button when you just hovering letter in gmail, i wonder how can i create similar button

I want to add simmilar buttons for my email, no idea what to search or how to create something like this


Solution

  • These are called Gmail Actions. You can check out Google’s documentation here: https://developers.google.com/gmail/markup/actions/actions-overview

    It’s basically a JSON-LD script element that you add to the <head> of your HTML email. For example:

    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "EmailMessage",
      "potentialAction": {
        "@type": "ViewAction",
        "url": "https://www.example.com",
        "name": "View Merge request"
      },
      "description": "Lorem ipsum dolor sit amet"
    }
    </script>