Google Analytics E-mail Tracking | Twilio SendGrid

Google Analytics (GA) is a great free resource that helps you stay on top of your website’s performance. But did you know that GA is also useful for monitoring your outbound emails? In this post, we’ll show you how to use Google Analytics email tracking to gain statistical insight into your campaigns. Plus, if you’re a Twilio SendGrid user, you’ll learn how to use our REST API to simplify the process.

How to track your email campaigns using Google Analytics

Tracking conversions from your email campaigns will help you understand how your emails perform and how to improve them. Follow these steps to learn how to generate a URL for an email campaign and track conversions in GA.

1. Sign up and install Google Analytics

First, head over to GA to sign up and integrate the tracking code into your website as directed. To obtain the results described in this post, you’ll need to verify that you properly set up your GA account.

2. Generate a URL to track inbound traffic from emails

With Google Analytics 4, the latest version of GA, you can track clicks on your email campaign by creating “Events,” then marking them as “Conversion events.” To do so, add query parameters to the end of your URL, then use GA to mark any page views with those query parameters as conversions. This helps you to distinguish between visitors who arrived at your site through an email campaign and visitors who arrived by some other means.

For example, let’s say you want to drive traffic to a specific page on your site: https://www.example.com/weekly-specials. You can add query parameters of your choosing, such as campaign_id, and give the URL a distinct value for your email campaign. The resulting URL to use in your email might look like this:

https://www.example.com/weekly-specials?campaign_id=winter-campaign-01

3. Set up a conversion event for your email marketing campaign

To start tracking conversions, you need to set up a “Conversion event” in GA. In the sidebar navigation, click on “Configure.” Then go to the “Events” page.

On the “Events” page, click the “Create event” buttons.

Now give your event a name. For example, winter_campaign_email_clicked. Next, set the conditions that indicate this event has occurred. For our custom event example, we have 2 conditions:

  1. the event_name want to page_view.
  2. the page_location (the referring link that brought the user to your site) will contain campaign_id=winter-campaign-01 (our unique query parameter distinguishing our email campaign).

Your custom event configuration will look like this:

Click “Create.”

Next, go to the “Conversions” configuration page. Select “New conversion event.”

In the “New event name” field, enter the name of the custom event you just created. For our example, that’s winter_campaign_email_clicked.

Click “Save.”

Now you can track each conversion from your email marketing campaigns in GA, giving you valuable insights into how your emails are performing.

4. Use the Twilio SendGrid API to send emails with custom URLs

the Twilio SendGrid REST API allows you to build an email program customized to your business. To track your email campaign conversions with this API, you will use the custom URL generated in GA. Plus, you can take advantage of several language SDKs to easily integrate email with your projects.

Let’s take a look at how to send an email using Twilio SendGrid with the custom email campaign URL link embedded. First, you’ll need to sign up for a free account. Shortly after you sign up, you’ll receive a verification email that’ll inform you when your account is active.

For our demonstration, we’ll use Twilio SendGrid’s Node.js SDK. To get started with the SDK, initialize a new Node.js project, then add the @sendgrid/mail packages:

~/project$ yarn init
~/project$ yarn add @sendgrid/mail

Next, save this code as a file called index.js, and put it in your project folder. Because this is an example mail sending application that you run at the command line, you’ll need to include a few environment variables when running the application:

  • API_KEY: This is your Twilio SendGrid account API key.
  • CUSTOM_URL: This is the custom URL for your email campaign that directs users to your site and includes your unique query parameter.
  • RECIPIENT_EMAIL: This is the recipient’s email address. (When testing, use an email address you can access so that you can verify you received the email and can click the campaign link inside.)

Below is an example of how to run this application from the command line:

~/project$ API_KEY=INSERT-YOUR-API-KEY-HERE
CUSTOM_URL=https://www.example.com/weekly-specials?campaign_id=winter-campaign-01
RECIPIENT_EMAIL=INSERT-YOUR-EMAIL-ADDRESS-HERE
nodeindex.js

Be advised that this application won’t work until you activate your Twilio SendGrid account.

After you’ve run the above application, you should receive an email in the inbox you entered for RECIPIENT_EMAIL. When you click on the URL within the email, GA will count this as a conversion. Next, we’ll look at how to view these conversions in GA.

5. Examine the data in Google Analytics

When your email recipients click on your campaign URLs, GA records those clicks in your statistics. To track these clicks, go to “Reports” in the GA navigation. Then, select “Realtime.”

Here, you’ll see tables for “Event count by Event name” and “Conversions by Event name.” (GA captures many different events by default.) As your site sees more activity on your site, including email campaign link clicks, more entries will show up in the “Event count” table. However, only those events that you marked as “Conversion events” will show up in the “Conversions” table.

You’ll recall that we defined a winter_campaign_email_clicked event and added it as a “Conversion event.” After clicking on the campaign link in the email you received, you’ll soon see a new conversion event in the Realtime report:

Dig deeper with Twilio SendGrid’s analytics

If you’re a Twilio SendGrid user, you have access to additional data that can help run more effective email campaigns. Simply log into your Twilio SendGrid account and click on the “Stats” tab to view your outgoing email statistics. The “Overview” page shows you the number of requests, delivered emails, clicks, opens, bounces, blocks, and spam reports.

Twilio SendGrid’s new Deliverability Insights dashboard, now in public beta, gives you even more actionable data insights. You can explore how each mailbox provider handles your emails, get tips on how to improve your email program, and optimize deliverability by understanding bounce classifications.

Learn more about tracking with Google Analytics and Twilio SendGrid, and read up on each platform’s tracking terminology and equivalencies.

Not a Twilio SendGrid user yet? Sign up for free today to get started.

Leave a Reply

Your email address will not be published. Required fields are marked *