Marketing Automation with SendGrid

9/17/2018

I first came across SendGrid while configuring a Google Cloud Compute Engine instance. Google blocks standard SMTP ports and suggests users route mail through third-party e-mail delivery services like SendGrid. These services offset the work of maintaining IP-based e-mail reputation and provide additional tools for contact management, e-mail marketing, and compliance with CAN-SPAM requirements.

With a sleek, modern UI, well-documented web API, and helper libraries in seven languages, SendGrid stands out in this space. Though it does not bill itself as a marketing automation platform, SendGrid’s rule-based segmentation, white-label click-tracking, inbound parse webhooks, and transactional messaging -- all free -- are comparable to Bronto, Oracle’s enterprise marketing automation platform.

Rule-based segmentation

Just like Bronto, SendGrid supports automated segmentation, though Bronto is far more powerful in this regard. SendGrid can segment on contact fields whereas Bronto can segment on dozens of criteria ranging from contact fields to engagement history (click rate, conversion rate, etc.), geoip (city, timezone, etc.), and platform (OS, mail client, etc.) Segments are more powerful than lists because they are automatically managed: you just need to define your inclusion criteria and the platform automatically adds and removes contacts as their eligibility changes.

For instance, imagine a site with multiple sections: news, reviews, and entertainment. Now say that each of these sections has a unique newsletter associated with it and we want to trigger the newsletters programmatically (for instance, when a section has a certain amount of new content). First, we create a segment for each section and associate it with an inclusion rule. For instance, the “News Subscribers” segment could be configured to include all users whose “news_subscriber” field is set to “1”. Now when a user engages in a particular action -- say they click a subscribe button on a call to action -- we just need to set their “news_subscriber” field to “1”. Later, we just need to target the News Subscribers segment and all eligible users (those whose “news_subscriber” field is set to “1”) will receive our newsletter -- no manual list management.

Secure link branding and click-tracking

Ordinarily, e-mail click-tracking is achieved by pointing links to SendGrid’s servers, where the engagement is recorded, and then redirecting the user to the link’s ultimate destination. The user doesn’t notice this but e-mail services do, which can hurt deliverability rates. SendGrid combats this by allowing you to configure secure link branding and click-tracking. This is achieved by configuring SendGrid to use your subdomain for click-tracking and proxying the traffic back to SendGrid. Instead of pointing links to a SendGrid URL, the platform will now point links to a URL on your subdomain, which is less likely to affect e-mail deliverability. Configuring link branding is simple:

First, you need to enable link branding in the admin panel:

Next, you need a DNS entry pointing from your branded subdomain to your server’s IP address:

A url.mail xxx.xxx.xxx.xxx

Finally, you need to proxy requests from the branded subdomain to SendGrid:

<virtualhost *:443="">
 ServerName url.mail.mugo.ca
 
 SSLProxyEngine on
 SSLProxyVerify none
 SSLProxyCheckPeerCN off
 SSLProxyCheckPeerName off
 
 ProxyPass / https://sendgrid.net/
 RequestHeader set Host "url.mail.mugo.ca"
 ProxyPreserveHost On
 <ifmodule mod_ssl.c="">
 SSLCertificateFile /path/to/fullchain.crt
 SSLCertificateKeyFile /path/to/privkey.key
 </ifmodule>
</virtualhost>

Once configured, the final step is to open a ticket requesting the feature be enabled (I received a response within 12 hours, over the weekend, while using a free account).

Inbound parse webhook

SendGrid’s inbound parse webhooks are easy to configure and open up a realm of possibilities. There’s just two steps:

First, you add your subdomain (e.g. incoming.mail.mugo.ca) and callback URL to the SendGrid inbound parse list. All messages sent to this subdomain will be forwarded to the callback URL.

Next, you add an MX entry pointing from your subdomain to mx.sendgrid.net.

That’s it, now any mail sent to any address on the subdomain will be routed to your callback script, where it can be parsed and handled (the message text is provided as a POST payload).


Transactional message support

Transactional messages are triggered in response to user actions (account creation, password reset requests, or purchases, for instance). Like Bronto, SendGrid provides a full-featured transactional message API; however, unlike Bronto, SendGrid differentiates between transactional and marketing message templates, meaning you cannot send a transactional message using a marketing template -- even though you could copy the HTML source of a marketing template and paste it into a transactional template.

A side-effect of this is that substitution tags in marketing templates (e.g. [%first_name%]) are resolved based on the user’s SendGrid field data, whereas substitution tags in transactional templates need to be passed to the API during the transactional message call. The practical implication is that before triggering a transactional message, you must first fetch the necessary field data to include with the transactional call. With Bronto, the syntax for API-provided substitution tags and Bronto-stored fields is different, allowing a single message template to use both.

Parting thoughts

SendGrid is a feature-rich e-mail delivery service and even the free tier stacks up well against Bronto. Though Bronto’s workflow triggers are extremely powerful, they don’t come cheap. Depending on your needs and budget, SendGrid might be the right choice for you.

Need to revamp your marketing automation workflows? Contact Mugo for a consultation!