Top
Displaying content based on User Roles
  • 06 Apr 2022
  • 4 Minutes To Read
  • Dark
    Light
  • PDF

Displaying 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 below.

Step 1: Creating 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. Navigate to the Whatfix Dashboard.
    Goto_dashboard

  2. In the left panel, click Tags.
    RB_dashboard_left_pane_tags

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

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

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

  6. Under Visibility Rules, select the desired criteria.

URL Hostname

The URL Hostname is the first part of any URL.

URL Hostname new.png

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

roletag_hostname.png

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

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

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

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

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

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

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: Associating 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. Navigate to the Whatfix Dashboard.
    Goto_dashboard

  2. Select the content you want to tag.
    RB_dashboard_select_flow_checkbox.png

  3. Click the Manage Tags icon.
    RB_dashboard_manage_tags_button

  4. In the popup, type the name of the tag and select from the list.
    RB_dashboard_content_tag_admin

  5. Click Done.

  6. Similarly, follow the above step to associate content to each role tags (editor, translator).

Step 3: Creating a segment

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,

  1. Navigate to the Whatfix Dashboard.
    Goto_dashboard

  2. Click Widgets.
    RB_DB_Click widgets(2)

  3. Select how you want to display the content. Here, the Self Help is selected.
    RB_DB_clickSH

  4. Click New Segment.
    RB_DB_SH_newsegment

  5. Enter the name for the segment.

  6. Click the + Select button.
    RB_DB_SH_clickselect

  7. Click Select by Tags.
    RB_dashboard_widgets_select_tags

  8. Enter the tag name and click Okay.
    RB_dashboard_widgets_select_tags_admin

  9. All the content associated with the tag is added.

  10. Now, under the Visibility section, select Role Tags.

  11. Select Exists and then select the tag (admin).
    RB_dashboard_widget_VR_role_admin

  12. Click the Plus icon to specify where you want to display the content.

  13. Here, URL is selected. However, you can use different parameters that match your criteria.
    RB_dashboard_widget_VR_role_url_conditions

  14. Click Save.

  15. Similarly, new segments have to be created for each role.


Was this article helpful?


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.