Skip to main content
Support

Accessing User Data in HelpDocs

You can pass user data to HelpDocs in either JWT auth or Shared Password as SSO. If you haven't already passed the data, check out the relevant article for more instructions. πŸ‘€

Taylor
Updated by Taylor
1 min read

You can pass user data to HelpDocs in either JWT auth or Shared Password as SSO. If you haven't already passed the data, check out the relevant article for more instructions πŸ‘€

Accessing Data

In your knowledge base you can access params from user_data by reading the hd_user_data cookie and decoding the JSON body.

Let's assume you've passed us this data for a user through JWT auth or Shared Password as SSO:

{
"name": "Taylor",
"user_id": 1
}

Then you can use a snippet a little like this one to access the data:

var user_data = {};
try {
user_data = JSON.parse(Cookies.get('hd_user_data'));
} catch (e) {
console.log('Error parsing user data');
}
console.log(user_data.name); // "Taylor"
console.log(user_data.user_id); // 1

You can include the above snippet in places like your live chat integration to identify your users, or in Settings > Customize > Code > JavaScript, then click Publish.

On our current templates, code in that tab runs before the Cookies helper has loaded, so this snippet needs to run after the page has loaded.
Any script on your docs can read this cookie, so don't pass us anything sensitive in user_data.
If your cookie consent banner is opt-in, this cookie is removed when a reader declines. To keep it, add hd_user_data to Essential cookies in Settings > Privacy & cookies.

What did you think of this doc?

Previous Setting Up and Using SAML Single Sign-On Next Restricting Your Docs to Logged In Users

Get in touch