1
Use the Engagement tracking and Metrics APIs
to bring insights to your business
Day 1 - Tuesday Nov 3, 2015
2
In this session
Make the most of the fine-grained information available on your customer behavior from SparkPost & Momentum
We’ll look at several ways to do that:
• Via the Reporting User Interface
• Via the APIs
• Via Webhooks event feeds in near real-time
3
OTHER CHANNELS
Recipients
ISPs
YAHOO
GMAIL
OUTLOOK
AOL
Message flow
Generate Message Deliver
Analyze
Multichannel
Powerful Templating
Big-Data Triggered Marketing
Automated Delivery Optimization
Adaptive Email Network
React in Real-Time
User Friendly UI
Big Data Feed
Sender
Real-Time Insight
Transmission API
One API
Transactional Messages 97.8%
Average Deliverability
Opens Clicks
Bounces OOB bounces Feedback Loop
messages
Reporting UI Metrics &
per-event API Webhooks
4
Example newsletter
Target segments? • Interested in
cats, dogs, or both
What type of customer?
• Loyalty card holder bronze/silver/gold
Campaign timing? Black Friday
5
Name your campaigns Use the “campaign_id” attribute – shows up in the Summary chart
{ "options": { "open_tracking" : true, "click_tracking" : true, "transactional" : false }, "campaign_id": "Bulk Pet Food Offers", "content" : { "from": { "name" : "Awesome Company","email":"[email protected]" }, "subject" : "Test SparkPost Transmission", "reply_to" : "Awesome Company", "text" : "Hi {{first_name}}\r\nTest email!\r\nCongratulations,\r\n{{signature}}", "html" : "<strong>Hi {{first_name}},</strong><p>Test email from <a href=\"http://messagesystems.com\">Message Systems</a></p><p>Congratulations!</p>{{signature}}" }, "recipients": [ { "address": { "name": "Bob Lumreeker", "email": "[email protected]" }, "tags": ["cats", "dogs"], "metadata": { "MemberType": "Gold" }, "substitution_data": { "signature":"Your friendly Solution Engineer", "first_name":"Steve" } } ], "substitution_data": { }, "metadata":{ "Sender": "BlackFriday1", } }
6
Name your content links data-‐msys-‐linkname custom attribute
https://www.sparkpost.com/api#/introduction/substitutions-reference/personalized-links
Max length of 63 characters (truncated if too long) Link name incorporated into the click-tracked link, will be tracked in engagement events.
7
Named content links in Engagement report
https://support.sparkpost.com/customer/portal/articles/2035637?b_id=7411
8
Passing information through metadata and tags
Tags: A list of single-values
• 10 per recipient, max 100 system-wide
Metadata: key-value pairs
• Recipient-level
• Transmission-level
(tags + metadata) max 1000 bytes
https://www.sparkpost.com/api#/reference/recipient-lists
9
Pulling information using the API • Everything that’s visible
on the Reporting UI, you can also get via the Metrics API (and then some) ...
• The message_events API endpoint gives access to fine-grained event information for up to 10 days:
Campaign ID Metadata Tags
10
Demo time!
11
API endpoints are self-describing https://api.sparkpost.com/api/v1/message-events/events/documentation
{ "results": [ { "type": { "description": "Type of event this record describes", "sampleValue": "bounce" }, "bounce_class": { "description": "Classification code for a given message (see [Bounce Classification Codes](https://support.sparkpost.com/customer/portal/articles/1929896))", "sampleValue": "1" }, "campaign_id": { "description": "Campaign of which this message was a part", "sampleValue": "Example Campaign Name" }, "customer_id": { "description": "SparkPost-‐customer identifier through which this message was sent", "sampleValue": "1" }, "delv_method": { "description": "Protocol by which SparkPost delivered this message", "sampleValue": "esmtp" }, "device_token": { "description": "Token of the device / application targeted by this PUSH notification message. Applies only when delv_method is gcm or apn.", "sampleValue": "45c19189783f867973f6e6a5cca60061ffe4fa77c547150563a1192fa9847f8a" }, "error_code": { "description": "Error code by which the remote server described a failed delivery attempt", "sampleValue": "554" }, "ip_address": { "description": "IP address of the host to which SparkPost delivered this message; in engagement events, the IP address of the host where the HTTP request originated", "sampleValue": "127.0.0.1" }, "message_id": { "description": "SparkPost-‐cluster-‐wide unique identifier for this message", "sampleValue": "0e0d94b7-‐9085-‐4e3c-‐ab30-‐e3f2cd9c273e" },
12
Webhooks
• Creating webhooks Via the UI .. or through API calls .. Can have many
• Security https transport option
• Authentication Choose between None,
Basic, or OAUTH2
13
Demo time!
14
Webhooks best practice
• Timing 60 second batches, or batch-size reached
• Your receiver code must http ACK Once you’ve committed the data Otherwise SparkPost will keep trying
• Check the Batch ID in the http header
X-‐MessageSystems-‐Batch-‐ID: 77c2b630-‐d712-‐11e4-‐9642-‐efc2723b99c1 User-‐Agent: SparkPost host: ec2-‐54-‐154-‐175-‐157.eu-‐west-‐1.compute.amazonaws.com accept: application/json content-‐type: application/json content-‐length: 9658 Connection: keep-‐alive
15
Webhook event types
bounce
delivery
injection
spam_complaint
out_of_band
policy_rejection
delay
click
open
generation_failure
generation_rejection
list_unsubscribe
link_unsubscribe
relay_injection
relay_rejection
relay_delivery
relay_tempfail
relay_permfail
https://api.sparkpost.com/api/v1/webhooks/events/documentation for full details !!
16
Focus on list hygiene
Processing the following event types is important for keeping your lists clean:
• Bounce
• Out-of-Band bounce
• Spam Complaint
• List Unsubscribe
• Link Unsubscribe
These events automatically add the recipient to the suppression list inside SparkPost, as a safety net measure.
17
Customer code in the public-domain
Financial Times have published their code for both Transmission API usage and Webhooks handling
18
Summary
We’ve seen how fine-grained information can be carried by • The campaign_id attribute
• Named links in templates and transmissions
• Metadata and tags
We’ve used that information via:
• The Reporting UI • Via the SparkPost APIs
• Via Webhooks near real-time event feeds