- 15 Jun 2022
- 4 Minutes To Read
-
Print
-
DarkLight
-
PDF
Display Content based on User Roles
- Updated On 15 Jun 2022
- 4 Minutes To Read
-
Print
-
DarkLight
-
PDF
Whatfix enables you to show different content to different users with the use of Role tags. For example, an admin user can be shown more and different content when compared to a basic user. This helps in targeting information based on what users can do on your application. Whatfix needs user information from your application to do this and one of the ways that the user's role is passed on to Whatfix is by using a window variable. Other ways to distinguish between users are also described in the following.
Step 1: Create Tags
Role-specific tags have to be created for each role. For example, if you have 3 different roles (admin, editor, translator) you have to create tags for each role.
Use the following steps to create a role tag,
-
On the Whatfix Dashboard, hover the cursor over the left panel, and then click Tags.
-
On the top right, click Create Tag.
-
Enter a name and description for the tag.
-
Click the Category drop-down menu and then select Role Tag.
-
Under Visibility Rules, select the desired criteria.
URL Hostname
The URL Hostname is the first part of any URL.
- Set the visibility rule to URL Hostname.
- Select the operator.
- Enter the url hostname.
URL Path
URL Pathname is the path section of the URL that comes after the hostname (domain) and before the query, including the initial slash if present.
For this to work, a unique url path has to be established in the URL for each roles.
- Set the visibility rule to URL Path.
- Select the operator.
- Enter the URL path.
URL Parameters
URL Parameters can be used if you want to identify a role using the parameters value of your URL. Parameters values are usually present in the URL after the question mark "?".
For this to work, a unique parameter value has to be passed in the URL for each roles.
- Set the visibility rule to URL Parameter.
- Select the operator.
- Enter the parameter value.
URL Hash
URL Hash can be used if you want to identify a role using the hash value of your URL. Hashes are usually present in Single page applications made using AngularJs or ReactJs. There are no page refreshes but only Hash changes.
For this to work, a unique hash value has to be passed in the URL for each roles.
- Set the visibility rule to URL Hash.
- Select the operator.
- Enter the hash value.
Other element on page
You can identify and use elements on the page that are exclusive to a particular role. For example, if there is a tab that is visible only to admin users, then you can use that tab as the Other Element on Page variable.
- Set the visibility rule to Other element on page.
- Select the selector type.
- Enter the selector value.
Window Variable
Window Variable means that the variable is being declared at the global scope and is accessible to any JS code. If the user role in your application is not declared as a window variable this cannot be used. Developers can help in getting the relevant window variable name and its value.
You don't need to add a window at the start for window variables.
- Set the visibility rule to Window Variable.
- Enter the variable name.
- Select the operator.
- Enter the variable value as mentioned in the code.
- Click Create.
- Similarly, follow the above steps to create tags for each role.
Step 2: Associate Tags to Content
Once you've created tags for each role, all the Whatfix content has to be associated with a tag.
For example, if you want to show a Flow called 'creating leads' to all the users then add admin, editor, and translator tags to the content.
-
On the Whatfix Dashboard, select the content using the checkbox for which you want to add tags.
-
Click the Manage Tags icon.
-
In the popup, type the name of the tag and select from the list.
-
Click Done.
Follow the above step to associate content to each role tags (editor, translator).
Step 3: Create a segment
Creating segments ensures where your end-users see content. A segment is created and configured with the necessary visibility rules so that relevant content is shown to the right role on the right page.
Use the folllowing steps to create a segment,
-
On the Whatfix Dashboard, hover the cursor over the left panel, and then click Widgets.
-
On the top right corner, click the Create button.
-
Select Self Help or Task List.
-
Enter the segment name.
-
Click the Select button.
-
Click Select by Tags.
-
Enter the tag name, and then click Okay.
All the content associated with the tag is added.
- Now, under the Visibility section, select Role Tags.
- Select Exists and then select the tag (admin).
- Click the Plus icon to specify where you want to display the content.
- Click Save.
You need to create new segments for each role.