Enabling HTTPS Engagement Tracking on SparkPost

June 8, 2017 Contributors

Overview

SparkPost supports HTTPS engagement tracking for all self-service customers. This article describes how to use a Content Delivery Network (CDN) to enable SSL engagement tracking for your domain. After completing the steps below, your email recipients will see HTTPS links in the email you send. When they visit a tracked link, your CDN will handle the SSL connection, then pass the HTTP request on to SparkPost. SparkPost will record the click event and redirect the recipient to the original URL.

Configuring SSL Certificates

In order for HTTPS engagement tracking to be enabled on SparkPost, our service needs to present a valid certificate that will be trusted by the email recipient’s browser.  SparkPost does not manage certificates for customer engagement tracking domains, as we are not the record owner for our customers’ domains.

As a workaround, you may use a Content Delivery Network (CDN) service, such as Cloudflare or Fastly to manage certificates and keys for any custom engagement tracking domains you configure.  These services forward traffic onwards to SparkPost so that HTTPS tracking can be performed.

How to Create a Secure Tracking Domain on SparkPost

In addition to SSL certificates, link forwarding, and page rules (see the step by step guide below), you will need to create a tracking domain with the tracking domains API using the "secure": true string. Detailed information on this operation can be found in our API documentation here.

How to Switch a Tracking Domain from Insecure to Secure

If you have previously created a tracking domain (whether verified or unverified), and wish to switch it from insecure (the default value for tracking domains) to secure, use the tracking domains API PUT call to update the tracking domain with the "secure": true string. Detailed information on this operation can be found in our API documentation here.

Step by Step Guide with CloudFlare

The following is a sample guide for use with CloudFlare only; please note, the steps to configure your chosen CDN will likely differ from CloudFlare in workflow. Please refer to your CDN’s documentation and contact their respective support departments if you have any questions.

  1. Create CloudFlare account

  2. Go to “DNS” tab on the CloudFlare UI:

  3. Add domain and then add the following Cloudflare NS records (please note, for other providers, the NS records to be used will differ):

    These values can be found under the DNS tab on the Cloudflare UI.

    Example:

    Using the domain track.example.com, below is a command line DIG command to confirm that the NS records have been updated to reflect the required changes:

  4. Create the appropriate page rule settings for the domain. In the page rules tab, perform the following instructions:

    • Page Rule Tab -> Create Page Rule
    • Enter your domain like so: track.yourdomain.com/*
    • Add a Setting -> Forwarding URL (you may need to specify a 301 redirect option)
    • Destination URL is https://<CNAME_VALUE>.io/$1. Replace <CNAME_VALUE> with the value displayed in the tracking domains section of the SparkPost UI.
    • Save and Deploy (turn page rule on)
  5. Cloudflare has Universal SSL for all accounts, but it’s good to ensure that setting on the page rule is "SSL". This is required for how CloudFlare will validate the certificate on the origin.

    More information on SSL options for Cloudflare can be found here.

  6. Turn the page rule ON.

  7. Add a CNAME entry into DNS for your tracking domain. The value in the record doesn’t matter; the record simply needs to exist. For example, if your tracking domain is track.example.com, a CNAME value of example.com is sufficient. Without a record to reference, the the page rule never gets triggered, and the proper redirection will not occur. Please note that the typical time to progagation of new CNAME records is often around five to ten minutes, but can be longer depending on your DNS provider.

  8. Run the Update a Tracking Domain API using the following Post Data:

  9. Navigate to the Tracking Domains section in the UI and click the orange "test" verification link. At this point, the process is complete.

Additional Resources for Content Delivery Networks

For a list of CDN providers (any of which can integrate with SparkPost to enable HTTPS engagement tracking), this page.