Google Analytics gives you the ability to track events so that you can monitor just about anything your customers do in your help center, including submitting tickets, clicking ticket deflection links, and sharing content. Events tell you how users interact with your content and are tracked independently of page loads. You enable event tracking by attaching a JavaScript snippet to the particular UI element you want to track. All user activity on such elements is calculated and displayed as events in the Behavior > Events section of the Google Analytics dashboard.
The article covers the following topics:
- Where do customers give up and submit a ticket?
- Which articles and posts are effectively deflecting?
- Are customers sharing the articles on social networks?
- What path do customers take in your help center?
To learn more about the code used in this article to track events in Google Analytics, see Event Tracking in the Google docs.
This is the third article in a series. The series outlines how to use Google Analytics to answer questions you may have as a Guide admin 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 - YOU ARE HERE
- Part 4 - Fine-tuning your help center
- Part 5 - Capturing help center user data
If you haven't already done so, enable Google Analytics in your help center. See Enabling Google Analytics. Also, some of the examples in this article include JQuery code. If you are using Guide templating V2, you'll need to import a jQuery library if you want to use jQuery statements in a theme. See About Guide templating versions and Importing or ugrading JQuery.
Where do customers give up and submit a ticket?
You can learn where in your help center customers give up and decide to submit a ticket. Most pages in a help center have a “Submit a request” link that lets customers submit a ticket using a Web form.
You can use Google Analytics to capture the URL of the page the customer is on when they decide enough is enough, they want to talk to an agent. Understanding what page a customer is on when they decide to jump ship is valuable for identifying areas of improvement in your design or content.
To enable tracking of pages where requests are initiated
- In Guide, go to edit the code for your theme, see Editing your help center theme.
- Open the script.js file in edit mode.
- Paste the "Capture submit request event" code below in the $(document).ready(function()
{ ... });
block:
Array.prototype.forEach.call(document.querySelectorAll('a.submit-a-request, .article-more-questions a'), function(submitRequestButton) { submitRequestButton.addEventListener('click', function(e) { var path = window.location.pathname; ga('send', 'event', 'Submit Request', 'Submit Request From', path); }); });
An event is recorded each time a customer clicks the “Submit a request” link. The path parameter captures the URL of the page that the customer was on when they clicked the button.
- Click Save, then click Publish changes.
- Verify that the event tracking is working. In the help center, click a couple "Submit a request" links. In the Google Analytics dashboard, go to Standard Reports > Real-Time > Events and check to make sure the events are captured.
Wait a few days to gather some data. Now take a look at the article pages where customers are deciding to submit tickets. Are there any surprises? Is there a page where you can tell customers are looking for an answer, not finding one, and thereby submitting a request? Look for ways to fix the problem so they don't have to resort to submitting a request.
Which articles and posts are effectively deflecting?
There is a built-in ticket deflection feature that automatically suggests related articles from your help center when a customer attempts to submit a ticket. The suggested articles are based on the content entered in the subject line of the request. If your customers see an article that might answer their question, they can simply click the link and go to the article. Hurray for one less ticket!
When a customer attempts to create a new community post, you can also offer suggestions for related community posts in your help center. The suggested posts are based on the content entered in the title of the new post.
To measure how well your articles and posts are doing at deflecting tickets and community questions, you can track the events.
To enable tracking of deflected ticket events for articles
- In Guide, go to edit the code for your theme, see Editing your help center theme.
- Open the script.js file in edit mode.
- Paste the "Capture ticket deflection event" code below in the
$(document).ready(function() { ... }); block:
$(document).ready(function() { // Capture ticket deflection event $("#new_request").on('click', '.searchbox-suggestions a', function(e) { var $this = $(this), link = $this.attr('href'); ga('send', 'event', 'Ticket Deflection', 'Deflect', link); });
An event is recorded each time a customer clicks an article suggestion. The tracking code also captures what articles are selected from the list of suggested articles.
- Click Save, then click Publish changes.
- Verify that the event tracking is working. In your help center, click a couple article suggestions on the Submit a Ticket page. In the Google Analytics dashboard, go to Standard Reports > Real-Time > Events and check to make sure the events are captured.
Use what you learn to identify the articles that are selected most often by customers wanting to submit a support request. It may be useful to promote the articles in your help center to draw more attention to them.
To enable tracking of deflected community post events
- In Guide, go to edit the code for your theme, see Editing your help center theme.
- Open the script.js file in edit mode.
- Paste the "Community Ticket Deflection event" code below in the
$(document).ready(function() { ... });
block:
$(".new_community_post").on('click', '.searchbox-suggestions a', function(e) { var $this = $(this), link = $this.attr('href'); ga('send', 'event', 'Community Ticket Deflection', 'Deflect', link); });
An event is recorded each time a customer clicks a post suggestion. The tracking code also captures which posts are selected from the list of suggested posts.
- Click Save, then click Publish changes.
- Verify that the event tracking is working. In your help center, click a couple post suggestions on the New Post page. In the Google Analytics dashboard, go to Standard Reports > Real-Time > Events and check to make sure the events are captured.
Are customers sharing the articles on social networks?
You can capture if and how your customers share your articles on social networks. Specifically, you can track each time a customer clicks a social sharing link in an article:
Aside from better understanding your customers' preferred social media channels, the metric helps you understand the virality of the articles in your help center.
The sharing component, {{share}}, must be present in the Article template of your help center theme. The component is not present by default in the Curious Wind and The Noble Feast themes. If you don’t have the {{share}} component or if you removed it, you can add it to your Article template. See Customizing the HTML.
To start tracking events in Google Analytics, you need to add some JavaScript (JS), code to your help center pages. The JS listens for a specific customer interaction such as a click. When it detects the interaction, it sends information about the event to Google Analytics.
To enable tracking of social sharing events
- In Guide, go to edit the code for your theme, see Editing your help center theme.
- Open the script.js file in edit mode.
- Paste the "Social sharing tracking" code below in the $(document).ready(function() { ...
}); block:
$(document).ready(function() { // stuff here // Social sharing tracking $('.share a').on('click', function(e) { var $this = $(this), type = $this.attr('class').replace('share-',''), path = window.location.pathname; ga('send','event','Social Share',type, path); }); // maybe more stuff here });
The type parameter captures the social medium that is clicked, (e.g. Facebook, Twitter, LinkedIn, or Google Plus). The path parameter captures the URL of the article that the user is sharing.
- Click Save, then click Publish changes.
- Verify that the event tracking is working. In your help center, click a couple sharing links. In the Google Analytics dashboard, go to Standard Reports > Real-Time > Events and check to make sure the events are captured.
What path do customers take in your help center?
Knowing the chronological order of actions by your customers in your help center can reveal their self-service behavior and habits. You can use Google Analytics to track this flow of events.
Before going any further, let's set up tracking of another common event that we haven't covered yet: searches.
To enable tracking of search events
- In Guide, go to edit the code for your theme, see Editing your help center theme.
- Open the script.js file in edit mode.
- Paste the "Capture search submit event" code below in the $(document).ready(function() {
... }); block:
$(document).ready(function() { // stuff here // Capture search submit event $('form[role="search"]').on('submit', function(e) { var $this = $(this), query = $this.find('input[type="search"]').val().toLowerCase(); ga('send', 'event', 'Search', 'Submit', query); });
- Click Save, then click Publish changes.
- Verify that the event tracking is working. In your help center, perform a couple of searches. In the Google Analytics dashboard, go to Standard Reports > Real-Time > Events and check to make sure the events are captured.
Now it’s time to string together all the events you're tracking to get a chronological view of your customers' actions. If you added and tested all of the events in this article, you should have four different event categories in your Google Analytics event reports. To recap, an event is recorded each time a user:
- shares an article on a social media network
- clicks the “Submit a request” button to create a ticket
- abandons submitting a ticket in favor of a suggested article
- searches on your help center
To determine the most common order of events
- In the Google Analytics dashboard, navigate to Behavior > Events > Event Flow.
The Event Flow report shows you the order in which users perform events in your help center. Click any of the categories in the first Event column to see the second, third, and fourth events that users performed afterwards. For example, you can see how many users searched your help center, then clicked “Submit a ticket”, then deflected to a suggested article they couldn’t find before.
That's all the event tracking we're going to cover. If you track other events that you find useful, please share them with us in the comments below.
53 Comments
@Zendesk -,Product Team
Reg,: Analytics/Tracking Click Results
How to know how many Clicks done on each Help Center Questions/Articles on same page without creating separate URL for each questions?
@Nigam - if I'm understanding you correctly, you're asking if Google Analytics can analyze how many times someone clicked on each individual article, which is possible. You shouldn't need any extra set-up. Here's a screenshot of it in Google Analytics to show you where to look: http://screencast.com/t/DVtAWZVqX
Hello. Regarding 'Where do customers give up and submit a ticket?', is there a way I can find out in GA how often users actually submit a request? Currently, it seems that as soon as someone clicks on the 'Submit request' button, the action is recorded which makes it difficult to analyse how many people do actually submit a request of the ones who have (perhaps accidently) clicked on the 'Submit request' button.
Thanks!
Hi Sandra! This is what I was able to come up with for tracking clicks of the 'Submit' button:
It isn't perfect - for example, it'll register an event even if the submission isn't successful - but hopefully it can get you started.
That's a good point, Sandra. The "Capture submit request event"/'Submit Request' would be better labeled "Capture initiate request event"/'Initiate Request'. Thanks for the code, Andrew.
Those examples (still) looks broken. I’m unable to get them to work unless I update and use them as suggested by Dom.
// Download tracking
$('.attachments a').on('click', function(e) {
var $this = $(this),
path = window.location.pathname;
attachment = $this.text();
ga('send', 'event', 'Download', path, attachment);
});
Notice the “ga(‘send’...” command. It shouldn’t be an array, as perhttps://developers.google.com/analytics/devguides/collection/analyticsjs/events
You are correct, the ga() function no longer takes an array. The syntax in the article has been updated.
Reference: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
Hi there,
I tried copying this code but the events aren't being captured. I really know nothing about javascript -- am I meant to replace any of the code with page-specific information?
Thanks!
Hi Brittany!
I see you're getting help with this issue in a ticket. Please feel free to come back and share your solution when you've got everything sorted out!
The majority of the results I am seeing after having added the tracking of search events code are "(not set)." Even the search terms I am checking myself don't populate in the search events but I assume are being added as (not set). How can I make sure all the search terms are being captured?
Hi Emma -
Interesting question here! To better troubleshoot this I would likely need to take a look at your Help Center and ensure the scripts for Google Analytics have been configured correctly. I am going to pull this into a ticket and will reach out to you soon!
Is it possible to use the deflection tracking event to track when someone clicks on a suggested article, and also if they went on the submit a request in the same session?
If one could record that someone was going to submit a ticket, but clicked on a suggestion, and then didn't, that could be taken a near-certain ticket deflection.
Hi Steve,
When an end-user is deflected from the article suggestions, they are sent there within the same window. None of our provided GA methods track the overall session of a user, only click events, so creating a 'link' between two different events wouldn't be possible.
In looking at Google's GA documentation, there's the potential for session cookie tracking which might accommodate what you're looking for:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id
Hi there, i
Is it possible to reference the Google Analytics Client Id to find out which HC he is?
Hi David,
Thanks for your question! I'm creating a support ticket with you, since exploring this may involve some questions about your account. I'll be in touch soon!
Thanks,
Daniel | Customer Advocate - Tier 1 | support@zendesk.com
Hello, I've copied the code in the JS section, but am unable to see the real-time events even after a few tries. are there any other possible reasons why I am unable to track on Google Analytics, the Events as described?
Hi Sue! It looks as though you have a support ticket open already, and our team is assisting with your specific code implementation. Generally speaking, however, so long as you are using this code and there is no additional conflicting JS, it should be fine. :)
I was putting in the search events tracking code and it is NOT tracking any of my search events unless I change
to
in the homepage file. For that reason, the code listed does not work. It seems that even if you press Enter, that doesn't count as a "submit". You would need to set submit=true and then re-style the submit button as well as the magnifying glass search icon.
If you don't want to do that, you can track when users press Enter to search with the following code:
Other suggestions:
I'd love it if we could also have event tracking code snippets for top article suggestion search result clicks and show the link of the clicked article in Google Analytics (Instant Search is built with Zendesk custom elements that are not viewable so I do not have anything to select).
I believe these would be helpful for everyone in having more insight into optimizing our Help Centers.
Hey Nicole -
Thanks for the feedback! I encourage you to re-post it in the Product Feedback topic in the Community so that our Product Managers will see it.
Is there a way to track if someone searched in the Help Center and then instead of pressing "enter" on their keyboard, they clicked on one of the top suggested articles within the search bar? Right now, the code only captures if you fully completed the search by pressing "enter".
Hi Grace -
That's probably a question for Google Analytics, but my guess is going to be that you'd need a third party tool like Pendo to track that kind of activity.
I'd like to set up an event that fires when someone clicks on "Yes" or "No" for "Was this article helpful?"
How do I do that?
Thanks!
Brook
Hey Brook -
You would need to play with the code, but you could use a javascript listener to pick up on when someone clicks those, and then have a custom form or whatever you'd like show up.
What kind of event are you trying to create?
Hi Nicole...I was trying to create an event that would fire every time someone clicked "Yes" or "No" for "Wast this article helpful?".
Then I could look in Google Analytics for our top 25 most trafficked support pages and understand which are helpful and which are not.
Hi Brook -
I checked in with some of our Guide experts, and they said that you should be able to achieve this with some javascript. We can't advise on the code specifically, but if you can find someone who's good at that stuff, you should be able to accomplish what you're trying to.
Hi.
Is the code still valid? I am using it but don't see any events.
Hi Andrei!
The code shouldn't have changed. Can you go into more detail about what exactly is going on?
Hi Jessie!
I am pasting the code as is into script.js file of the theme and publish changes – but I don't see any live events firing when events-related actions are done.
Hey Andrei!
Can you be more specific about what code you're using? Are you using all the code snippets in this article, or just specific ones? What do you mean by "live events firing", just that an action is taken and doesn't show up in GA? How are you testing whether these actions are being taken?
I am just using code snippets from the article. This one i.e. for the ticket submission events tracking.
Yes, I use most of them and I don't see any events in GA interface for this actions - real-time OR not. I am testing by doing these actions from my browser (tested from different computers). Could you check if the code is still valid? The guidelines for adding snippets to Guide theme look outdated (there is no more JS tab i.e. in this UI) - maybe code is too.
Please sign in to leave a comment.