Who's looking at your Tableau Public visualisations?
Updating Analytics tracking for Google Tag Manager
I followed the instructions in Jeff's post, but Google have now produced Google Tag Manager, so this blog provides an update of the steps you can take to install tracking with Google Tag Manager. Doing so hugely simplifies the setup of Google Analytics tracking in Tableau Public dashboards, once you've got the initial setup in place.
How does tracking Tableau Dashboards with Google Tag Manager differ?
Google Tag Manager is intended to make it easier to manage a whole range of events on a website by configuring tags within Tag Manager, rather than having to code things into website scripts. For those of us who aren't hard core web developers, it means providing flexible tracking tools, without having to get down into the guts of scripts and coding quite as much as before.
What if I already have Google Analytics tracking set up on my website?
- Setting up a Google Tag Manager account for your site. You'll get a new unique 'GTM' ID number for your site (just like your old Google Analytics tracking ID code).
- Replace any existing Google Analytics ID code with the new GTM ID code snippets.
- Set up any Analytics ID codes you still want to use for website tracking as Google Tag Manager tags and trigger events.
- Use Google Tag Manager to set up Analytics Tracking
- Create a single Google Analytics Tracking ID to track all my Tableau visualisations
- Create a single template HTML code file using Google Tag Manager's tracking code
- Use a copy of this template file, with a unique filename, to distinguish each dashboard
- Remove the need for a unique Tracking ID, code and shortened URL link for every dashboard.
How do I set up Tag Manager to track Tableau Dashboards?
- Go to 'variables' and click 'new' under 'user defined variable'
- Call it 'Tableau Analytics Tracking ID' (or something similar)
- Click in 'variable configuration' to set it up
- Scroll down and pick 'Google Analytics Setting' as the variable type
- Enter the Tracking ID you created in Step 3 and click 'Save'
- Click 'tags' on the left side of the dashboard
- Click 'new' to create a new tag
- Name your tag - I called it 'Tableau Analytics Views Tag'
- On 'tag configuration', click and select 'Google Analytics - Universal Analytics'.
- Leave the track type as 'pageview'
- Under 'Google Analytics Settings' you'll see the variable name you just created (which holds the tracking ID code). Pick this.
- Click under 'triggering' to set up a new trigger
- Click '+' in the top right to create a new trigger event
- Call the trigger 'Tableau Analytics Page Viewed'
- Choose the trigger type of 'Page View'
- Select 'Some page views'
- Change the setting in box 1 to 'Page path'
- Change the setting in box 2 to 'matches RegEx'
- In box 3, enter a regular expression that defines the pathname we used for our site
- In my case this is \/analytics\/(.*)
- If you've used a different pathname, just use that pathname
- This is a regular expression, so you need to use a \ character before the / to ensure it's read as /analytics/
- If you're not a regular expressions guru, this is saying that the trigger will fire whenever the page pathname contains /analytics/ anywhere. That's why we need to use a unique directory name that doesn't appear anywhere else in your website in step 1.
- Save this trigger and then save the Tag page as well
- When a file on your website with Google Tag Manager code in it is opened, it wakes up
- If the file has the pathname /analytics/ it will send the page information to Google Analytics, under the Tracking ID Code you provided for Tableau Analytics.
How to publish a new dashboard with unique Google Analytics tracking
- Take a copy of the template GTM code file and call it the name of your new dashboard
- Exactly as per Step 4 in Jeff Shaffer's original article, create a web object somewhere on your dashboard. Set the URL to be the filename you've just created (in full, with your site name)