Google Analytics gives you the ability to capture additional information on a Hit, Session, User, or Product. This section will focus on capturing data on Users, but this same technique can be applied to Hits, Sessions, and Products just as easily.
This is the fifth article in a series. The series outlines how to use Google Analytics to answer questions you may have as a Guide manager responsible for providing an effective self-service support option to your customers. The series covers the following topics:
- Part 1 - Asking the right questions
- Part 2 - Measuring the effectiveness of search
- Part 3 - Tracking customers' actions
- Part 4 - Fine-tuning Help Center
- Part 5 - Capturing Help Center user data - YOU ARE HERE
If you haven't already done so, enable Google Analytics in your Help Center. See Enabling Google Analytics.
Capture a user's role in Google Analytics
For any logged-in user in Help Center, Zendesk can pass Google Analytics information on their role if they are logged in. A user in Help Center has one of the following roles:
- manager: This is a logged-in agent with admin privileges
- agent: This is a logged-in agent with standard privileges
- end_user: This is a logged-in end user
- anonymous: This is a user in Help Center that is not logged into Zendesk
To enable the capture of custom dimensions with a user's role
- Log in to Google Analytics and go to the Admin tab.
- Under the Property tab for your project, click Custom Definitions, then Custom Dimensions.
- Click New Custom Dimensions.
- Add a new dimension named "User Type" scoped to a User and make sure it is set to Active, then click Create.
- In Guide, go to edit the code for your theme (see Editing your Help Center theme).
- Open the script.js file in edit mode
- If your theme is using Templating API v2, paste the "Capture submit request event" code below in the DOMContentLoaded block:
document.addEventListener("DOMContentLoaded", function(){
//send user role to Google Analytics
var userRole = HelpCenter.user.role;
ga('set', 'dimension1', userRole);
ga('send', 'event', 'Help Center', 'Page view', {'nonInteraction': 1})
}); - If your theme is using Templating API v1, paste the "Capture submit request event" code below in the jQuery $(document).ready(function() { ... }); block:
$(document).ready(function() { //send user role to Google Analytics var userRole = HelpCenter.user.role; ga('set', 'dimension1', userRole); ga('send', 'event', 'Help Center', 'Page view', {'nonInteraction': 1}) });
Make sure the dimension numbers match the values for the custom variables you have in your Google Analytics account.
You should then have a report of Help Center pageviews by user role: