Tealium’s Advanced Webhook

Webhooks are Everywhere
It seems these days that everyone has a Webhook feature.  You can fire Webhooks in Github when you commit code.  You can send Webhooks in Trello when you create a card.  Slack will let you set up an incoming or outgoing Webhook.  Odds are good you will answer “Yes” to the survey question, “Do you expect to build webhooks in the next 3-6 months?”  There is a good chance you’ll create a Webhook integration just because you can.

So what is a Webhook exactly?  Even if you think you know, you should still go here to watch the hour-long video just to make sure.

Tealium Webhooks
Tealium has a good number of built-in integrations for client-side or cloud-delivery of your event and visitor data.  Many of these integrations act a lot like a Webhook and will pass specific vendor-formatted data over HTTP POST.  But let’s say you want to build your own.  There’s a new cutting edge analytics service out there your college roommate built and you’d like to overload his servers with data.  Your pal was a little too-smart-for-his-own-good and decided to deviate from the traditional key/value pairs and build a multi-level hierarchical JSON structure format to receive data.  Of course he wrote great documentation on using Webhooks for incoming data.

Let’s take a few steps back.  You’ve already implemented Tealium’s data layer on your web site.  And you’ve even installed a Tealium Collect Library on your IoT device.  These data sources are arriving at their AudienceStream destination as a set of event attributes.  It seems like a long shot to translate the data to the custom format.

Just before you give up… you realize Tealium’s Webhook supports custom templating similar to what you already know from semantic template technologies Handlebars and Mustache.  No need to change your IoT device code or modify your website JavaScript, just define a new custom Webhook in Tealium.

A Real-World Use Case?
Personally, I’d like to know when someone is reading my blogs.  Let’s say many people can’t get enough of my blog entries and are asking themselves if I might be the next Charles Dickens.  I’d really appreciate getting a thumbs-up emoticon notification in Slack when this happens.  And, I’d like to know this in real time.  When someone reads three of my blog posts in the same visit, I must know immediately.  Of course this may end up being a distraction from getting things done, but the regular positive vibes are sure to improve my brain’s effective productivity.  I’d also like to know which specific articles were read (the name of the articles appearing in Slack alongside my thumbs-up message ?).

(1) I’ll start with the end in mind.  After reading their docs, Slack appears to be able to receive this as an incoming Webhook in the following format:

Webhooks-image-0The /BLAH/BLAH/BLAH endpoint is specific to me and I’m keeping that confidential.

Side note: I had to have a Tealium Slack Admin give me the approval to use Slack’s Incoming Webhooks feature (Browse Apps -> Custom Integrations -> Incoming WebHooks -> Edit configuration)

This test works, I can see the Slack message resulting from the curl.

(2)  Now, I can setup a simple JSON template in Tealium’s Webhook Connector to send the same information in the same way.  I have already configured a filtered stream called “test” so my Webhook will only fire from my test page (for now).

 

webhooks-image-1

(3) Now that my test worked, I can create the rules and enrichments in the Tealium Universal Data Hub for my specific use case.

I have a simple rule called “Ty Blog Article View” that is used by two enrichments.  The first keeps the blog post titles (post_title) in a Set of Strings.  The second is a Number that stores the number of blog post pages viewed.

webhooks-image-3
(4) Configure Audience in AudienceStream

I’m changing the Source of the Webhook to be visitor-based instead of my original test that was event-based.  That means I need to create an Audience.  My Audience is when someone has viewed three pages of blog type with author Ty Gavin.  When someone joins this Audience in their current visit to tealium.com, I get notified immediately.  Here is my Audience definition.

 

webhooks-image-4

Here is event data that AudienceStream will use — the incoming data as seen in Universal Data Hub monitoring tool “Live Events” is below:

webhooks-image-5

The following shows how I configure the Webhook to read the data from my set of blog titles and send along to Slack.

Here is my AudienceStream Webhook template that adds the articles names and the emoticon to the slack message.  I had to read Tealium’s documentation to learn how to reference each of the 3 titles in my Set of Strings.

Here’s what it looks like in my Slack notification:


TIP:
When testing, you can set the Webhook URL config value to a “http://requestb.in/” location instead of going directly to Slack’s endpoint to start with.  That way, you can see the exact data sent and confirm it will comply with Slack’s desired format.

If you enjoyed reading this article, here are two other blog posts that you might want to consider reading:

Google AMP HTML and Tealium

Be Strategic in Optimizing Web Site Performance

Recommended Posts