3 Replies Latest reply on Aug 1, 2015 2:23 PM by Daniel Leventhal

    User Agent Detection

    Robert Rouse

      Strangely, I'm finding that people are attempting to run a web data connector inside a normal browser rather than the Desktop application. Are others finding the same thing?


      I'm thinking of adding user agent detection to warn people that it won't work when accessing it via normal browser. What user-agent should I use for that? I vaguely recall seeing that somewhere but can't seem to find it.

        • 1. Re: User Agent Detection
          Daniel Leventhal

          Hi Robert,

          While you could look for a user agent, that might be fragile. You can always go into the WDC web browser and go to What's My User Agent? if you like.


          I think a more robust way might be to detect if tableau.init() is ever called. If you aren't running in the simulator or in Tableau, nothing will call that function.



          • 2. Re: User Agent Detection
            Robert Rouse

            Here's how I solved the problem. On my index.html page, I have this script (below) to check if the person is accessing from within Tableau. If so, they are redirected to the actual connector page. If not, they stay on this page which gives them some instructions on what to do. If there's a cleaner way I'd be interested to see it.


                    var myConnector = tableau.makeConnector();
                    //redirect if initialized in Tableau
                    myConnector.init = function () {
                    //required functions
                    myConnector.getTableData = function () { };
                    myConnector.getColumnHeaders = function () {};
            • 3. Re: User Agent Detection
              Daniel Leventhal

              Hi Robert,

              Sorry for the delay. I was thinking of something a little different. I think it is better in some ways, but worse in others:


              var myConnector = tableau.makeConnector();

              var hostedInTableau = false;

              myConnector.init = function() {

                   hostedInTableau = true;




              $(document).ready(function() {

                window.setTimeout(function() {

                  if (!hostedInTableau) { 

                    // do something to alert the user they need to view this page from Tableau's WDC

                    alert("This page is designed to be used from within Tableau's WDC interface");


                }, 100);



              This method is not as clean, but it keeps everything in a single file.

              I'm curious if you or anyone else has another idea of how to detect this in a clean manner.