1/18/2017
Using Google Analytics to Track Your Tableau Visualizations


Back in November at the Tableau conference, a few of the Tableau Zen Masters had the opportunity to meet with Ben Jones and a few members of the Tableau Public team. One of the things discussed was the want for better tracking capabilities of visualizations on Tableau Public, more than just total views which is displayed at the bottom of each viz. This got me thinking about other ways to track these visualizations. After all, most users of Tableau are data geeks who want to have more data. When publishing a visualization on Tableau Public, I'd like to know things like the number of views of the visualization over time rather than just the cumulative total, the geographic distribution of these viewers and device information (mobile vs. desktop, PC vs. Mac or the various browser types) so that I can design my visualizations accordingly.

These are the exact same things tracked on websites. I use Google Analytics to do this for my websites and they have a great platform to track all of these things. Tableau even has a native data connections so you can connect your Google Analytics account instantly to Tableau for a deeper analysis. So why not leverage this platform for your Tableau Public visualizations too?

Here's what you'll need to do this:

1. A Google Analytics account (free).
2. A hosting server to host a webpage.
3. A little JavaScript code that Google will provide you to put on an HTML page.

Step 1: Create a shortened link for your Tableau Public Visualization


Google Analytics won't accept a URL for a Tableau Public Visualization so the first step is to create a shortened link. I use Bitly.com to do this. Go to the Tableau Visualization that you want to track. Select "Share" on the bottom of the viz and copy the URL link that is provided.

For this example, I input the URL link from my Rainy Day Visualization. The shortened URL returned by Bitly was tabsoft.co/2hWFRZi.

Step 2: Create Tracking in Google Analytics


I set up a "new account" in my Google Analytics account called "My Data Visualizations". You are allowed up to 100 Google Analytics accounts per Google user account and then websites are listed under each account that you set up. I use the name of my visualization, for example "Rainy Day Viz" as the name of the website in this new account. For the website address, enter the Bitly address created in Step 1. Note - the Tableau Public URL will not work in Google Analytics.



Once this is created, copy the JavaScript tracking code provided by Google Analytics. This is also under "Admin" then "Property" and "Tracking Info".

Step 3: Create an HTML Tracking Page


Below is what the Google Analytics tracking code looks like placed inside of the HEAD tag on an HTML page. Save this page to your hosting server.



Step 4: Add this Webpage as a Web Object to a Dashboard


The webpage can be blank and can match the background color of the viz. It can be very small and placed anywhere out of the way on the visualization. It could also be placed as a floating object behind any other floating object on the dashboard. The goal is to have a webpage object hidden on your visualization. Another option is to color the webpage background and use the webpage object as the entire background for your visualization with floating tiles on top of it. In my Rainy Day Viz example, I added the Google Analytics to the webpage that hosts the animated GIF that I am using as the background image. Note - you won't be able to use Dashboard URL actions if using this method unless it's a secondary webpage object, otherwise the dashboard action will update this Google Analytics tracking page.

Once this is saved up to Tableau Public with the new webpage object, Google will start tracking data that is received when the Tableau visualization is loaded. Note: This will also work on Tableau Server and it will even work on Tableau Desktop, tracking how many people open the workbook in the wild, because the webpage will load when someone opens the viz in Tableau Desktop if they are connected to the internet. In this case you might want to set up two tracking numbers, one for online tracking and one for desktop tracking. You can track most things in Google Analytics with the exception of the channel source of the traffic (since it's coming direct from Tableau).

Here is an example showing real-time views of a Tableau Public Visualization.



Here is the geographic location of the visitors. In this case, my own views from Cincinnati, Ohio.


We can now track the views to a Tableau Public Viz over time. This is my Rainy Day Viz


And here's the geographic location of the viewers.



I hope you find these tips helpful. If you have any questions feel free to email me at Jeff@DataPlusScience.com

Jeffrey A. Shaffer
Follow on Twitter @HighVizAbility