Tracking Drupal Roles from Google Analytics

Roles are tracked by default

Out of the box, the user roles you assign to people are tracked by Google Analytics as a default setting. It's understandable if you have concerns over how this might affect your site's web traffic numbers, so if reviewing your analytics on a regular basis is an important part of maintaining your web presence, we'll show you how to hide user roles from Google.

Step 1. Add user roles to Google Analytics Module

Please note: this step requires the user to be a Site Manager. If you do not have this role, please contact your site manager.
  1. In your SiteFarm site, navigate to Manage » Configuration » Google Analytics.
  2. Click the Custom Dimensions tab to open settings.
  3. Scroll to the bottom of the settings and click on Browse available tokens.
  4. Open current user and scroll down to Roles and open the drop-down copy the [current-user:roles] token and paste it in Index number 1 value.
  5. Click Save configuration to finish.


Step 2. Setting up Google Analytics

These instructions presume you already have your Google Analytics accounts and know how to navigate through the settings.
  1. Navigate to the Admin section in Google Analytics and in the center column click on Custom Definitions then click on Custom Dimensions from the drop-down menu.
  2. Click NEW CUSTOM DIMENSION and add a custom dimension called "User Roles".
  3. Navigate to Behavior » Site Content » All Pages.
  4. Click on Secondary dimension to open the drop-down menu, then open Custom Dimensions and select User Roles.

    Your output should look like the screenshot below. If so, you’re set up.
    Please note: this may take up to a half-hour to update. If you don't see any changes just refresh the browser.


Step 3. Filter by Role Type (optional)

If you would like to filter by certain roles you can use the advanced search feature.

  1. Click on advanced link located in the upper right part of the screen to open advanced settings
  2. Click on Page tab highlighted green to open menu options.
  3. Click on User Roles from the list.
  4.  In the text field enter which role you would like to view then click Apply button.image

    You will now see that all other roles have been filtered out.