- 06 Apr 2022
- 4 Minutes To Read
-
Print
-
DarkLight
-
PDF
Displaying content based on User Roles
- Updated On 06 Apr 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 below.
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,
-
Navigate to the Whatfix Dashboard.
-
In the left panel, click Tags.
-
On the top right, click Create Tag.
-
Enter a name and description for the tag.
-
Click the Category drop-down menu and select Role Tag.
-
Under Visibility Rules, select the desired criteria.
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 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 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 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.
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 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.
Note: 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.
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.
-
Navigate to the Whatfix Dashboard.
-
Select the content you want to tag.
-
Click the Manage Tags icon.
-
In the popup, type the name of the tag and select from the list.
-
Click Done.
-
Similarly, follow the above step to associate content to each role tags (editor, translator).
Creating segments ensures where your users will 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,
-
Navigate to the Whatfix Dashboard.
-
Click Widgets.
-
Select how you want to display the content. Here, the Self Help is selected.
-
Click New Segment.
-
Enter the name for the segment.
-
Click the + Select button.
-
Click Select by Tags.
-
Enter the tag name and 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.
-
Here, URL is selected. However, you can use different parameters that match your criteria.
-
Click Save.
-
Similarly, new segments have to be created for each role.