How to track emails in Gmail

Learn how to track emails in Gmail. We will explore how to use an Email API to configure email tracking using Gmail.

hero banner for blog post

The code in the blog post has been updated to work with Nylas API V3.

Introduction

In this blog post, we dive deeper into tracking emails in Gmail. Email tracking is important because it allows us to understand how our readers engage with emails. If we better understand what emails are engaging, we can iterate and improve our email communication with existing potential customers. To learn more about email tracking, consider taking a look at what is email tracking. This technical post focuses on how to implement email tracking in Gmail.

Benefits to tracking emails in Gmail

Let’s go over the benefits of tracking emails before we take a look at how to track emails in Gmail.

Improving productivity

Tracking emails allows for better email communication management with respect to prioritizing responses. When we track email, we can determine whether the email is open and read, allowing us to take the necessary next steps, such as sending a follow-up email.

Gaining valuable insights

Learning about recipient engagement and behaviour toward your email communication is valuable to determine the effectiveness of email campaigns. Using this information, you can iterate and improve your messaging going forward and learn how to tailor your message to different audiences better.

Streamlining communication

Tracking email further streamlines communication with your users. For example, if a user reads an email, it may prompt a different follow-up versus an email that was left unread. In the scenario where an email was read by the user, such as a receipt or transaction, we may not require a follow-up email. If an email was unopened, we may want to prompt the user with a follow-up email.

Real-time email tracking

By learning about your user’s engagement with your email communication in real-time, you can build out certain follow actions relevant to a specific event. Real-time tracking is useful since the email will be relevant to the user as they have just engaged with it, such as opening it, reading it, or clicking on a specific link.

Why track emails in Gmail?

Gmail is ubiquitous as an email platform and is part of millions of businesses day to day workflow. Let’s look at use cases to track emails in Gmail.

Track sent emails in

We can track emails successfully delivered to the recipient’s email address. Tracking sent emails is important to ensure the message reaches our users. Tracking sent emails is an important part of improving email deliverability.

Track if email is read

Another way to track emails in Gmail is by checking whether the recipient has read the message. Knowing whether the email is opened is important when contacting the recipient with a follow-up for further actions.

Track email opens

Ensuring an email is opened is important to know if the recipient has engaged with the email message. Tracking email opens is important to understand whether the recipient accessed the email message. This is also useful for tracking as we can know the exact moment the recipient opens the email.

Link tracking

Another useful item to track is whether the user clicked on any links found within the email message itself. Another indicator of email engagement is the user finding the content useful and continuing to engage by clicking on the call to action found within the email.

Understanding Nylas for email tracking

Nylas powers your application’s email, calendar, and contacts. Let’s focus on our Nylas Email API for email tracking. We offer different ways of email tracking:

  1. The first method is a connected account where the user has authorized access to their email account to your application. We’ve covered how to track open email rates using the connected account approach.
  2. The second approach is where emails are sent using the Nylas Email API can be configured with tracking enabled. This way, you can track emails for any recipients, whether the email was opened, links clicked, or any replies in the thread.


The second approach to track emails does not require a connected account and provides real-time email tracking through the use of Nylas webhooks. We’ve covered how to setup webhooks with NodeJs and how to develop with webhooks locally using the Nylas Node SDK:

How to track emails in Gmail, step-by-step:

1. Setting up Nylas to track emails in Gmail

To get started with Nylas, consider using the Quickstart Guides to grab the code for sending an email, with environment setup details included. We provide Quickstart Guides in Python, Node, Ruby and Java. We recently covered using the Quickstart Guides on Coding with Nylas:

For the step-by-step guide, we will be using the Node SDK.

2. How to track sent emails in Gmail

In this section, we will look at tracking sent emails in Gmail. Let’s take a look at the code available in the Quickstart Guide to send emails in Gmail:

app.post("/nylas/send-email", async (req, res) => {
  try {
    const sentMessage = await nylas.messages.send({
      identifier: process.env.USER_GRANT_ID,
      requestBody: {
        to: [{ name: req.body.sendTo.name, email: req.body.sentTo.email }],
        replyTo: [{ name: req.body.replyTo.name, email: req.body.replyTo.email }],
        subject: req.body.subject,
        body: req.body.body,
      },
    });

    res.json(sentMessage);
  } catch (error) {
    console.error("Error sending email:", error);
  }
});  

Given the above code, once the email is sent, we will receive a message that we can use to determine if the email was sent successfully. If a message was not received, we could check for error responses received. We can also update the code to handle error messages better:

try {
  // Add system logging for successfully sent message
  const message = await nylas.messages.send(/* send data */);
  return res.json({ message }); 
} catch(error) {
  // Add system logging for unsuccessfully sent message
  return res.json({ message: error });
}

In this section, we explored how to track sent emails in Gmail.

3. Track email opens

Let’s take a look at ways to track email opens. We’ve covered this in-depth in our blog post on how to track email open rates, where we also discuss checking open rates in Gmail and Outlook! Taking the above code sample from the Quick Start guide for sending emails, let’s modify the .send() to include tracking options for tracking email opens:

  requestBody: {
    ...
    trackingOptions: {
      opens: true,
    },
  },

This section explored how to track email opens in Gmail.

4. Link tracking

Let’s consider ways to track when a link is clicked. We are going to take the previously shared code sample for sending emails and modify the draft.send() to include link tracking:

  requestBody: {
    ...
    trackingOptions: {
      links: true,
    },
  },

This section explored how to track email links in Gmail.

Build time!

You can sign up for Nylas for free and start building! Nylas provides different approaches for tracking email engagement through connected accounts and real-time tracking using webhooks. Here are links to additional resources:

Consider building using our Quickstart Guides to accelerate your development and try out Nylas Email API tracking functionality.

You May Also Like

Nylas_Email_Activity_Capture_For_Salesforce_1
Capture all customer email activity in Salesforce to drive GTM alignment
Send Emails using TinyMCE Rich Text Editor
The Nylas mascot, Nyla, standing next to a scheduling UI
Introducing Nylas Scheduler v3: Experience the future of in-app scheduling

Subscribe for our updates

Please enter your email address and receive the latest updates.