In what context are you doing this in? An HTML Widget or an HTML Tile? Or is this coded into a Theme somewhere?
This is coded within our theme. (We have been granted special access to add custom CSS/JS in our Jive-x Cloud theme.) It has been placed within the Site Header HTML box within the Theme Builder.
Our primary use case for defining the variable is to capture it in our third-party analytics tool (Omniture) to provide context to our reports. (i.e. filter out employee traffic and only show customer traffic.)
If you want userType to be a global variable, leave off the var when you declare it.
var userType = 'Unknown'; // Instead of this userType = 'Unknown'; // Do this. Leave off the "var".
Wow, I can't believe it was that easy!! That did the trick!
I was also able to display the variable in an HTML widget using the code below.
document.getElementById("displayType").innerHTML = 'User Type: ' + window.parent.userType;
Thanks Dominic, you're a lifesaver!