We Are Hiring

How To Track Your Emails Using Google Analytics


Posted on

Google Analytics ( GA ) is a great free resource to 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 show you how to use GA to gain statistical insight into your outgoing emails. If you are a SendGrid user, you will also learn how to use our REST API along with our free GA filter to simplify the process.

Sign Up and Install Google Analytics

First, you need to get setup with GA. Head on over and get signed up and integrate the GA code into your website as directed. In order to obtain the results described in this post, you will need to verify that your GA account was setup properly.

Setting Up the Links in Your Emails to Work with Google Analytics

GA has made it very easy to create custom URL’s that integrate into GA via their URL Builder. Simply fill out the form and click the Generate URL button.

Once you have generated the link with the URL Builder, you can use them inside of your outgoing email and GA will auto-magically track clicks to those URLs in your GA account.

Tracking Conversions

To track conversions in GA, you will need to define and setup your conversion goals.

There are three basic steps:

  1. Create a descriptive name, such as “Sign up for free trial”.
  2. Define each URL that leads up to the page where the conversion happens, this is usually the “Thank You” page after a successful transaction.
  3. Assign a dollar value to the conversion.

Once you have completed those steps, you can use the “Goals” link on the left navigation area within GA to view conversion data such as the number of overall conversions, the value of those conversions and conversion rate. To dig deeper, check out this in-depth treatment from SixRevisions.com.

Using the SendGrid REST API and Google Analytics Filter to Simplify the Process

To try out this method, you will need to sign up for a free account at SendGrid.com. Shortly after you sign up you will receive a verification email that will inform you when your account is active.

I will be using PHP for this example; however, you may also find Perl, Python and Ruby examples at our online documentation.

Here is the directory structure used for this example along with links to the appropriate files:
/Swift-4.0.6 – download
/smtpapiheader.php – download
/index.php – download

I suggest you read through the index.php code, updating the settings and credentials as you go through. Then, you can run the code on your local environment or on your web server by simply entering the root URL that contains the index.php file. Be advised that this code will not work until your SendGrid account has been activated.

Examining the Data in Google Analytics

Once the recipients of your emails begin to click on your URLs, those clicks will be recorded in your Google Analytics statistics. Here are the steps to locate that data:

  1. Login to your Google Analytics account.
  2. Click on “View report” next to the appropriate account.
  3. Click “Traffic Sources” on the left navigation area.
  4. In the same area, click “Campaigns”.

Note that Google Analytics does not display data in real time, so it will take a few hours before you start to see the data.

Within this view you can obtain data such as visits, pages/visit, average time spent on your site, percentage of new visits, etc.

Take a look at this article by MakeUseOf.com, which explains how to gain the most advantage from this method of email tracking.

Dig Deeper with SendGrid’s Analytics

If you are a SendGrid user, you have access to additional data that can help you become even more effective with your email campaigns. After logging into your SendGrid account, click on the “Statistics” tab to view your outgoing email statistics. The data on this page shows you the number of requests, delivered emails, clicks, opens, bounces, blocks and spam reports.

You can also obtain a downloadable list of all the bounced, blocked, unsubscribed, spam reported and invalid emails by clicking the “Email List” tab and the appropriate sub-tab.

We want to hear your experiences, we love great feedback and collaboration. How are you currently tracking data on your outgoing email? Have you used SendGrid’s Google Analytics filter? What was your experience? Ideally, what type of data would you like to be able to track?

Keep up to date on the latest SendGrid news by subscribing to our blog rss feed and/or follow us on Twitter.

Tags: , ,


Elmer Thomas is SendGrid's Hacker in Residence. His mission is to help SendGrid live up to its slogan: "Email Delivery. Simplified" by improving the lives of developers, both internally and externally. Via all sorts of hackery, of course. Follow his exploits on Twitter and GitHub.

3 thoughts on “How To Track Your Emails Using Google Analytics

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>