Top
Display Content based on User Roles
  • 15 Jun 2022
  • 4 Minutes To Read
  • Dark
    Light
  • PDF

Display Content based on User Roles

  • Dark
    Light
  • 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,

  1. On the Whatfix Dashboard, hover the cursor over the left panel, and then click Tags.
    CLMDashboard_tags

  2. On the top right, click Create Tag.
    RB_dashboard_tags_create_tag

  3. Enter a name and description for the tag.
    RB_dashboard_tag_name_description

  4. Click the Category drop-down menu and then select Role Tag.
    RB_dashboard_tags_role_tag

  5. Under Visibility Rules, select the desired criteria.

URL Hostname

The URL Hostname is the first part of any URL.
RB_DB_CR_URL Hostname new

  • Set the visibility rule to URL Hostname.
  • Select the operator.
  • Enter the url hostname.

roletag_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.

URL path new

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.

roletag_pathname

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 "?".

URL parameter new

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.
    roletag_parameter

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.

URL Hash new

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.

roletag_hash

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.

visibility_element_css_selector

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.

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.

visibility_window_var

  1. Click Create.
  2. 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.

  1. On the Whatfix Dashboard, select the content using the checkbox for which you want to add tags.
    RB_dashboard_select_flow_checkbox

  2. Click the Manage Tags icon.
    RB_dashboard_manage_tags_button

  3. In the popup, type the name of the tag and select from the list.
    RB_dashboard_manage_tags_plus_button

  4. Click Done.

Info

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,

  1. On the Whatfix Dashboard, hover the cursor over the left panel, and then click Widgets.
    RB_EDT_clickwidgets

  2. On the top right corner, click the Create button.

  3. Select Self Help or Task List.
    Dashboard_Click_SH

  4. Enter the segment name.
    RB_DB_New_Segment

  5. Click the Select button.
    RB_DB_SH_clickselect

  6. Click Select by Tags.
    RB_dashboard_widgets_select_tags

  7. Enter the tag name, and then click Okay.
    RB_dashboard_widgets_select_tags_admin

Note

All the content associated with the tag is added.

  1. Now, under the Visibility section, select Role Tags.
  2. Select Exists and then select the tag (admin).
    RB_dashboard_widget_VR_role_admin
  3. Click the Plus icon to specify where you want to display the content.
  4. Click Save.
Info

You need to create new segments for each role.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.