How To: Collect Twitter Data with IFTTT
Prior to the 2016 Tableau Conference I thought it would be fun to collect Twitter data around the conference hashtag, #Data16, in order to visualize the amount and type of social engagement that the conference would create. You can see these dashboards here (#Data16) and here (Wrap-up: #Data16). The most important question that came out of that exercise was "how do you collect Twitter data". There are a number of approaches you can take including using web data connectors a tool like Alteryx, or a scraper like Import.io, but I used a combination of IFTTT and Google Sheets to create mine. Here's how I did it!
Create Google and IFTTT Accounts - You'll need to have a Google account as well an IFTTT account in order to get this done. We're going to be using a website/program called IFTTT, which stands for "If This, Then That". It uses simple Applets to let you easily create code based on a call and response. For instance you can create an applet that when a picture of you is posted on Facebook, it will be saved to your Dropbox account. First thing you'll need to do is sign-up for an account (it's free).
Select IFTTT Applet - For our use, we're going to use a pre-assembled Applet that creates a new row of data in Google Sheets every time someone tweets a specific hashtag. It's called "When a specific hashtag is used on Twitter add the Tweet to a Google spreadsheet". Catchy!
Start Applet - To get started, click on the gear in the upper right hand corner of the applet.
Edit Applet - Now you have to specify what hashtag to track (#data16, in this case), as well as the name of the new spreadsheet name, and whether you want to create a new folder in Google Drive. If you really want to get clever, you can also change the code to denote what information you want pulled into the sheet.
Save the Applet - Click save at the bottom of your Applet. This will take you back one screen, so just make sure that the applet now read as "ON". You've done the heavy lifting. Now it's time to reap the rewards!
Connect Tableau to Your Google Sheet - Open up Tableau as you normally would and select "Google Sheets" from the "Connect" view. You'll be asked to login to Google Sheets from here.
This is a great no-frills way of collecting tweets about a specific topic. There is also a number of ways you can tweak this to get additional benefit. For instance, you can add a split function to the Google Sheet in order to split a tweet into individual words and get word counts across all of the collected tweets. I've also used this to collect my sleep data from Fitbit and to have my Amazon Echo call my phone when I can't find it.