Enhanced Tableau Telemetry?
Returning to form for another “did you know you could do x with Tableau?” entry, here in this long overdue post, I explain how to capture interaction telemetry with Tableau without needing a Tableau extension.
It just requires a table to capture the telem, and some reverse thinking in the code. [And the ability to execute stored procedures (sproc(s)).
Why? When Tableau Server already provides a comprehensive telemetry capture that can be accessed simply by activating the built-in read-only account?
It’s a simple one really: firstly, the read-only telemetry details everything about workbook publishing, and updates, and about which users are opening which pages, but this is about it. Tableau Server does not log interactions with visuals, buttons, or actions, so the developers are still largely unaware as to how their visuals are being used, or if elements could be retired or redesigned.
Furthermore, the telemtry db is only available for Tableau Server. Due to the shared-nature of Tableau Cloud, this activity is disabled for the security of all the server users, which means that only the telem workbooks provided by Tableau are the only telem available direct from the server; and the other telem extensions really only provide capture at the java-script level.
I first created this method waay back in the mists of time of 2008, needing to use Excel to insert data into a database table, I then needed to alter this to allow the same from SSRS (SQL Server Reporting Services), and so altering again for Tableau in 2014, whilst not entirely difficult, it can be a little more fiddly.
And back in 2014, the user needed to want their interactions to be captured, as this needed to be through a specific button programmed to collect this. But now, following the 202.2 release of parameter actions, it is now possible to set these auto-captures to silently collect the data for onward analysis and development.
Here, I shall be demonstrating how to capture the details of a user who is interacting with a NavToURL function, inserting into an SQL Server table
*** Caveat ***
This uses parameters to capture the data, so as long as a parameter is updated as part of an on-click interaction operation, then this can be captured.
Quick filters cannot be captured as yet, although I'm working on this - I swear I worked this out sometime ago but cannot remember how.
For this demonstration, I shall capture 5 items, of which 4 of those come from Tableau:
Date/Time - uses GetDate() this is captured by SQL Server as part of the insert
workbook name
type
user
activity
During setup, set your parameter representing the activity capture (telem_activity) to either an asterisk (*) or to the word "setup", as these two will bypass the insert statement.
Create Procedure tableau_telem.sp_tableau_workbook_telem (@workbook_name Varchar(100),
@telem_type Varchar(100), @telem_user NVarchar(100), @telem_activity Varchar(200)) As
If @telem_activity = 'setup' Or @telem_activity = '*' GoTo bypass_capture
Insert Into tableau_telem.dbo.tableau_workbook_telem
Select
telem_date = GetDate()
,workbook_name = IsNull(@workbook_name, 'None')
,telem_type = IsNull(@telem_type, 'None')
,telem_user = IsNull(@telem_user, 'None')
,telem_activity = IsNull(@telem_activity, 'None');
bypass_capture:
Select GetDate() As current_datetime;
As you will know, whilst Tableau can query stored procedures, these are designed to execute a query, and so any changes to the pass-through parameters will initiate another query, so you do need to be careful in how you setup.
And, as part of this, Tableau will refuse to connect to a source that doesn't produce data, so the sproc will always return the current date/time [GetDate()] in order for this function to work.
Step 1:
Configuration is now down to you, make sure you have created and configured string parameters for the following before you connect to the sproc, and keep the connection as live - do not convert to an extract.
The parameters and their corresponding sproc parameters:
p_telem_workbook_name = @workbook_name : set to your workbook name
p_telem_type = @telem_type : initally can be null, you will define later
p_telem_user = @telem_user : will always reference the Username() Tableau function
p_telem_activity = @telem_activity : initially set as "setup" (without quotes), but shall be setup by you later
You can name these Tableau parameters to anything of your choosing, but it makes sense for the name to be as descriptive as possible.
Next-up, connect to the sproc by dragging the sproc onto the canvas: [your-data-server].[your-database-name].[your-schema].[your-sproc-name] connecting your Tableau parameters to their sproc counterparts.
Step 2:
And now for the workbook configuration. In order for this to work, you do not need any data to come from the proc, just a reference to it needs to be placed onto the dashboard which is going to contain the data capture, and so this can be anything such as using a sheet as:
your company logo
the dashboard title
A hover-over (tool-tip) help
a section separator
sheet filter
Once this is in place, then parameter updates shall be picked-up and passed out to the awaiting sproc.
Finally, the sheet that we're tracking, configured in preparation for capturing this NavToURL action.
For the data table, create a calculation to capture the users ActiveDriectory name using the calc Username() save as something like telem_name, and drag onto the sheet detail card.
Next, the type.
I'd recommend using a calculated field here in case you have multiple types of activity you want to capture across different sheets, as this shall free you to be able to define any type of action here. Or, if you have a list list of defined types, you could use this.
So, another calculated field call it something like telem_type, populate the calc with a string descriptor, so I'd use something like 'navigate to URL', save and then add this to the detail of the visual.
And now, the final config on the dashboard. Remember, for this, I want to capture the url as indication for interaction, and so, in addition to the existing nav-to-url function, you need to define the following three Change Parameter actions:
All for the same sheet
(target = source)
p_telem_type = telem_type
p_telem_user = telem_user
p_telem_activity = nav_to_url - the calculated field you are already using the navigation function
And that's all there is to it.
Just be sure that after testing, that your p_telem_type and p_telem_user parameters have been reset to blank, and that your p_telem_activity parameter has been returned to “setup” before publishing otherwise their values will be captured each time a user opens the dashboard.
Now, when the call is put out to navigate to the url, the parameters shall be updated, which alongside your pre-populated workbook name parameter, and the GetDate() within the script, your defined telemetry shall be captured.
On another note, Tableau requires all defined parameters to be populated, even though we know that script-side, parameters can be ignored. And so, all parameters in the script can take nulls recording as "not recorded" if you did need to ignore a telemetry capture - at present we capture only necessary items, so we have no reason to avoid this now, but going forwards, should we add other capturable data, this might become more reasonable.
Also published at Tableau Community