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, name, and email in Google Analytics
For any logged in user in Help Center, Zendesk can pass Google Analytics information on their role and name if they are logged in. A user in Help Center has one of the following roles:
- manager: This is an logged in agent with admin privileges
- agent: This is an 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 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', 'pageview');
}); - 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', 'pageview'); });
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:
69 Comments
Hey Kay,
I've just updated the document to give both the Native and jQuery versions. Thanks for the code snippet!
Hi Madison Davis. I tried to add the JQuery code but unfortunately no luck. My Google Analytics account still does not have the user role data. My template is Templating API v1 so I cannot switch to using the other code listed in the article's instructions. Is there anything else I can try?
I'm trying to track the external_id of an organization of a user (NOT the user's external id) but for some reason, my code is sending undefined. The organization name is showing up correctly in GA but nothing for the external ID.
Is this the correct way to capture the external id?
Hello there - can anyone tell me what happens to Google Analytics history when users in Zendesk get deleted? Does it also get deleted in Google Analytics? Thanks!
Hi Kasia,
No it doesn't get deleted automatically.
Google Analytics and Zendesk are always managed separately.
Usually you'll never share users personal information with Google Analytics.
Thanks for totally ignoring my question, for 2 months!
Hey Naghmeh,
Apologies as it looks like we may have missed your question! I'm going to reach out internally as well as our mods to see if they know a way to accomplish this. I'll follow-up once I have more information to provide.
Thanks!
Hey Naghmeh Anvari
The external_id property is not available in that helper.
I don't believe it's possible to fetch the external id of an organization (or a user for that matter) from the API either. The best you can do is add the external_id as a tag or in the name of the organization (in other words expose to the available properties of HelpCenter.user.organizations[0].
Has anyone got the Org tracking with GA4? Is it possible?
Please sign in to leave a comment.