Google Analytics and Help Center - Part 5: Capturing Help Center user data

Have more questions? Submit a request

39 Comments

  • Dan Craig
    Comment actions Permalink

    Thanks for posting this article, very helpful! Three questions:

    • Can we use the same js format to pass through other variables, such as organization or tags?
    0
  • Jason Maynard
    Comment actions Permalink

    Hey Dan,

    Answer below.

    #1. You can use either. Not sure if there is an advantage in using one or the other, but would love to know if you find out.

    #2. Oops! Don't do that :) Removed that section from the article.

    #3. Yep. The same format should be able to used to pass through any variable.

    Thanks for the feedback.

    Cheers,

    Jason

    2
  • Carl Alingalan
    Comment actions Permalink

    Hi Jayson Maynard,

    i have encounter a problem when capturing the user data, i followed every step that is in the article but doesn't show for me the User roles even the User Emails. it doesn't show any data

    please help me i'm stuck.

    0
  • Jessie Schutz
    Comment actions Permalink

    Hey Carl!

    Can you post a screenshot of the code you put in the JS editor? I'm not super familiar with JS, but my educated guess is that there's a problem there.

    0
  • Micah Mount
    Comment actions Permalink

    Hello! I'm experiencing the same problem; if anyone can help me see what I'm missing I would be REALLY appreciative!

    I see user sessions in GA but am not seeing the user data for signed in users. And just to clarify--there have been signed in user sessions.

    We have the custom dimensions created and the JS in the Guide (see snippet below), then I set up a new Dashboard in GA to view the data, I see sessions elsewhere, but no sessions that are reporting the `user_role`

    GA custom report under Customization > Dashboards > New report:



     

    Here are the results from the Dashboard:

    Screenshot from our JS file in our custom theme:

     

    And here's the exact code that I pasted in:

    ```

    //Google Analytics User Data capture a la https://support.zendesk.com/hc/en-us/articles/204279766
    var dimensionValue = HelpCenter.user.role;
    ga('set', 'dimension1', dimensionValue);

    var dimensionValue = HelpCenter.user.name;
    ga('set', 'dimension2', dimensionValue);

    var dimensionValue = HelpCenter.user.email;
    ga('set', 'dimension3', dimensionValue);

    ```

     

    Again, any help would be GREATLY appreciated!

     

    1
  • Tim Finney
    Comment actions Permalink

    Hi Micah,

    I'm struggling with this myself, but one thing I noticed }); is missing from the end of your JS code. See screenshot below. I'm not sure if this solves your problem but figured I would point it out.

     

    Thanks,

    Tim

     

    1
  • Micah Mount
    Comment actions Permalink

    Hi Tim,

     

    Thanks so much for pointing this out. I had wondered about that, but as I'm not very familiar with JS I wasn't sure if the function needed to be closed there, or just at the end of the function.

     

    So far, I've had no luck with any of the tweaks I've tried, but I'll be sure to report back if that fixes things. 

     

    Thanks again!

    Micah

    0
  • Tim Finney
    Comment actions Permalink

    No problem.

    Zendesk- I'm having quite a bit of trouble myself with this and would appreciate any help.

    1. I created two custom dimensions: 'User Role' and 'User Name'
    2. I pasted the string listed in my previous comment into the Help Center. Can someone confirm if that looks correct? A few of my values are still in white which makes me think they are incorrect.
    3. Can you show us the report setting for the 'User names and emails' report you show on your dashboard?

     

    Thanks,

    Tim

    0
  • Micah Mount
    Comment actions Permalink

    Hey Tim,

    Try adding :

    ga('send', 'pageview');

    to the end of your script. This seems to have worked for me. I'm still working to verify that I'm getting all of the correct data; but now I am seeing at least some data in GA (whoot!).

     

    ~Micah

     

    0
  • Tim Finney
    Comment actions Permalink

    Thanks, Micah. Unfortunately, that hasn't made a difference yet. Could you possibly post your code and report settings?

     

    Thanks,

    Tim

    0
  • Micah Mount
    Comment actions Permalink

    Hi Tim,

    Happy to. From what I'm seeing in GA the sessions report takes a day or so to populate though.

     

    JS in our custom theme:

    $(document).ready(function() {

    //Google Analytics User Data capture a la https://support.zendesk.com/hc/en-us/articles/204279766

    var dimensionValue = HelpCenter.user.role;
    ga('set', 'dimension1', dimensionValue);

    var dimensionValue = HelpCenter.user.name;
    ga('set', 'dimension2', dimensionValue);

    var dimensionValue = HelpCenter.user.email;
    ga('set', 'dimension3', dimensionValue);
    ga('send', 'pageview');
    });

     

    Custom report options under Customization > Custom Reports > New:

     

    Custom Report results:


     

    As I said, looks like data takes about a day to populate, and I'm completely new to GA so I'm not sure if this is the best way to view/slice this data, I'm just happy to see that we're starting to ingest it... now I can get someone who is more familiar with GA to set up any needed segments, reports, views, etc.

     

    I hope this helps you in your quest! 

     

    Best,

    Micah

    0
  • Tim Finney
    Comment actions Permalink

    Thank you, Micah! I really appreciate it. I'm finally seeing user data. I'm not sure what user data you want to see, but I'm most interested in seeing the email address of each user. So, I created the below report to show each user's email address and I filtered for 'end_user'. 

     

     

    Best,

    Tim

    0
  • Jennifer Rowe
    Comment actions Permalink

    Hi Micah and Tim, Glad you both got this sorted this out. Nice teamwork! :) 

    But I wanted to let others know that we did have some problems in our article. It's just been updated, so hopefully anyone else who comes along and wants to implement this won't struggle! 

    Thanks to Becca on our support team for the updated version!

    0
  • Micah Mount
    Comment actions Permalink

    Hi Jennifer,

    I really appreciate Becca's help--she was instrumental in getting data to populate in GA; appreciate the great support! And thanks for updating the article to include the suggestions she made--this will be really helpful for folks--thanks again!

    0
  • Jennifer Rowe
    Comment actions Permalink

    Glad to hear it, Micah! Thanks for coming back with the shout out to Becca. She is great.

    Glad she helped you solve your problem and was able to update this article for others!

    0
  • Avil Mascarenhas
    Comment actions Permalink

    The link at - 
    If you haven't already done so, enable Google Analytics in your Help Center. See Enabling Google Analytics

    doesn't lead to enabling google analytics page

    Should it refer to - https://support.zendesk.com/hc/en-us/articles/205402318-Enabling-Google-Analytics-for-your-Help-Center

    0
  • Nicole - Community Manager
    Comment actions Permalink

    You're correct, Avil. Thanks for pointing that out! I've fixed the link in the article.

    0
  • Lila Kingsley
    Comment actions Permalink

    Can someone advise whether you can include custom role information?  We are interested in user data for our agents in our internal knowledge base (used only by our agents in our call center and not customers/the general public).  This article seems to only provide  how to get the basic roles of end user, agent, manager, anonymous....but these aren't very helpful for an agent only Help Center. 

    I do see there was some concern in the comments about what google allows (https://support.zendesk.com/hc/en-us/articles/204279766/comments/115001269747), but that really seems to be regarding personally identifiable information, and I don't think custom role would be considered something personally identifiable.

    0
  • Ryan McGrew
    Comment actions Permalink

    Hi Lilia,

    This information is not included in the HelpCenter.user object but could be obtained via an API call to /api/v2/users/me.json. This will expose the custom_role_id. You'd likely want to cache that information via a cookie or local storage in the browser to reduce load times and the number of API calls.

    Thanks!

    0
  • Lila Kingsley
    Comment actions Permalink

    Thanks Ryan! 

    Can you advise if the help center user object is the following?  I am not sure as it doesn't appear to contain HelpCenter.user.role which the code ZD supplied in this article.  https://developer.zendesk.com/apps/docs/help-center-templates/objects#user-object

    Also, can you advise if there are any reference materials on executing an API call within the help center?   I have searched and come up empty except for the following article...which is about troubleshooting a null result on a call to /api/v2/users/me.json (caused by having a host mapped help center):  https://support.zendesk.com/hc/en-us/articles/115008781728-Using-the-endpoint-users-me-json-in-Guide-returns-an-Anonymous-user-object

    This seems like something we'll need to hand off to our engineering team but I would like to understand the effort.

    Thanks

    -Lila

    0
  • Ryan McGrew
    Comment actions Permalink

    Hey Lila, 

    I'm referring the HelpCenter.user object used in the JavaScript code samples in this article. For example this

    var userRole = HelpCenter.user.role;

    You'll need to use JavaScript to make an AJAX call to that API endpoint and parse the results to get the custom role. You can see the output of this by going to https://support.zendesk.com/api/v2/users/me.json for our HelpCenter when you're logged in. Or replace our domain, with your domain to see it on your HelpCenter.

    The article you've referenced has sample code on how to execute this AJAX call and advises you to use the relative URL to access the API rather than the absolute URL when you have a host mapped HelpCenter.

    So the JavaScript will look like

    $.getJSON("/api/v2/users/me.json", function(data) { 
    console.log(data.user.custom_role_id);
    });

    Instead of

    $.getJSON("https://support.subdomain.com/api/v2/users/me.json", function(data) { 
    console.log(data.user.custom_role_id);
    });
    0
  • Lila Kingsley
    Comment actions Permalink

    Thanks Ryan.  Is there documentation on what is available in the HelpCenter.user object?

    0
  • Ryan McGrew
    Comment actions Permalink

    Hey Lila,

    There isn't specific documentation for it but it should largely follow the definition of the end user when an end user is logged in and the user object when an agent or admin is logged in.

    Thanks!

    0
  • Dylan Cunniffe
    Comment actions Permalink

    Is there any way to send a user's external id to GA?

    0
  • Ryan McGrew
    Comment actions Permalink

    Hey @Dylan,

    If you have access to that value via JavaScript you should be able to set it as a custom dimension you send to GA.

    Thanks!

    0
  • Thomas Crowley
    Comment actions Permalink

    Hi. The code in the instructions is:

    var userRole = HelpCenter.user.role;
    ga('set', 'dimension1', userRole);
    ga('send', 'pageview');

    But in the comments, Micah and Tim use the following code, apparently successfully:

    var dimensionValue = HelpCenter.user.role;
    ga('set', 'dimension1', dimensionValue);
    ga('send', 'pageview');

    Should I be entering 'userRole' or 'dimensionValue'?

    Thanks!

    0
  • Ryan McGrew
    Comment actions Permalink

    Hey Thomas,

    userRole and dimensionValue are just variable names in the JavaScript, so it doesn't matter what you call it as long as it's consistent. The code is actually identical and will send the same data to Google.

    Thanks!

    1
  • Thomas Crowley
    Comment actions Permalink

    Hi,

    I've had this set up on our Sandbox site for a few days now, and it's still not returning any data in the custom report.

    The code:

    The report settings:

    The custom dimension:

    Is there anything in the above that looks off? Or are there any suggestions why it might not be returning any data?

    Thanks!

    0
  • Ryan McGrew
    Comment actions Permalink

    Hi Thomas,

    Just wanted to verify that you've enabled Google Analytics in you Sandbox account's Help Center and that you're looking at the proper tracking ID (Google will allow you to generate multiple tracking IDs so you can set up test accounts).

    Assuming that looks good, I would take a look at the Google Analytics Debugger for Chrome which should report the calls and data being made in the JavaScript console of the browser. I would also look at the JavaScript console to verify if there are any JavaScript errors in your code.

    Thanks!

    0
  • Thomas Crowley
    Comment actions Permalink

    Thanks Ryan, I must confess to knowing very little about JS, however on line 116 of my code I have identified an

    Uncaught SyntaxError: Unexpected token } 

    which is a result of me closing the function too early (on line 12 of the code I pasted above). It now seems to be executing more commands, and is sending the information to GA, I guess I'll wait and see if it trickles through.

     

    Thanks for your help again!

    0

Please sign in to leave a comment.

Powered by Zendesk