Wednesday, September 10, 2014

How to Embed Streaming Web Content in Tableau

Tableau is a great, if not the best, tool for building data visualizations.  But what the tool also includes is the ability to display content from the internet right in your viz!  Here is the how to for streaming that content, and I will be using my "Weird Al" viz as the template for this.

1. Build the Data Set

If you want an interactive viz that dynamically displays different web content, you first need to build a data set that shows the different components you want to stream.  In the case of "Weird Al", I wanted to stream his individual songs and albums, so I went to Wikipedia for his discography and copied it into a spreadsheet. 

  • Just like any other Viz, a content viz is still data driven, so be sure you have the most robust/cleanest data you can work with
Album data with various attributes
Song data with various attributes

2. Gather the web links

In a "How-To" guide that allowed me to even build out this idea, +Ben Jones wrote about embedding YouTube into Tableau.  The key is that regardless of your content source (YouTube, Spotify, Soundcloud, etc), you want to find the 'embed' url to leverage in your dashboard.  In Spotify, these can be found by right clicking on a song and selecting 'Copy Embed Code'
The resulting code will look something like this, and the URL that you want is highlighted in yellow: <iframe src="" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>

That URL can be copied to your Excel data like so
It is very important to line up the correct URL to the correct record in the data

  • Regardless of web source (YouTube, Spotify, Soundcloud, etc), identify the Embed url the desired content, and include that in your data source

3. Build a Dashboard That Will Stream the Web Content

In your viz, design your dashboard however you wish.  For the "Weird Al" viz, I wanted people to be able to select an image of the original artist and then be able to play that song.  Here is what the resulting Tableau sheet looks like
The field containing the URL needs to be in the details of the worksheet
In the dashboard, add the worksheet as well as a Web Page item.

After adding Web Page, select 'OK' to continue.  It's okay to leave it blank
With the URL is part of the details, the URL can be triggered from the dashboard via an action.
Add the sheet to a dashboard, then select Dashboard -> Action
The type of Action to add is a URL action
Check off the sheets you want the action to work from, and then select the field that contains the URL you wish to stream.
Select the arrow, then select the field that has the URL
After that, you can now stream by making a selection on the specified sheets (in this case Parody Song - Images and Parody Song - Lists) and the url listed in the data will appear in the web part.

  • After placing a Web Page part on your dashboard, you can use a URL Dashboard Action to pull the streaming content from the selected data point.

BONUS POINT. Custom Hyperlink Text

In the section above, the url action was delivered using a 'Select' URL action.  That means when a component of the specific worksheet is clicked on then the action will take place.

Tableau also offered 'Menu' actions, meaning that when you hover a specific data point, a URL link appears in the tooltip for you to select.  The advantage here is that you can variablize the text in the tool tip.  For example, the links could looks something like this...

This is easy enough to do.  Start with the URL action just like before

Select the 'Menu' action, and whatever you put in the Name will be what's displayed to the user.  You can even variablize the name by including values from the data, in this case Song title.

  • Actions can be selection or text based.  The text based actions, however, can be customized to display a message to the user relevant to the data point they are hovering on.

Conclusion: Steaming Web Content is Easy and Awesome in Tableau!
So there you have it, a breakdown of the how to embed steaming web content in your Tableau dashboard.  Check out the original viz for the interactive experience.