Help Center user segmentation using Google Analytics custom dimensions

40 댓글

  • Paul Fennell

    Hmmm....

    this code snippet seems to break my javascript when I place it in:

     

    //Google Analytics User Variable

    _gaq.push(['_setCustomVar',1,'User Role', HelpCenter.user.role,1]);

    0
  • Sandra Weigl

    Updated code to reflect the library change from ga.js to analytics.js:

     // Google Analytics User role
     ga('set', 'dimension1', HelpCenter.user.role);
     ga('send', 'event', 'Zendesk', 'Users', 'role', {nonInteraction: true});

    0
  • Tony Roma

    Updated to reflect a better workflow and avoid using ga('send', 'pageview');

    We're trying to segment actions based on user tags for paid customers, staff, other (logged in, other tags), and anonymous (not logged in).

    GA dimension is set to a User-level scope. We'll also pass this through with a non-interaction event, so we don't double our pageviews.

      // Google Analytics user tag dimension
    var tag="";
    if (HelpCenter && HelpCenter.user.tags) {
    var staff_user = (HelpCenter.user.tags.indexOf("staff") > -1);
    var paid_user = (HelpCenter.user.tags.indexOf("paid") > -1);
    if (staff_user === true) {
    tag = "staff";
    }
    else if (paid_user === true) {
    tag = "paid";
    } else {
    tag = "other";
    }
    } else {
    tag = "anonymous"
    }
    ga('set', 'dimension1', tag);
    ga('send', 'event', 'ZenDesk', 'UserType', tag, {
    nonInteraction: true,
    });

    0
  • Sandra Weigl

    Hello, I am using several custom dimensions (added in the JS code). I have one ga 'send' function below the custom dimensions to get the data into Google Analytics. However, since a page hit is already created by default, I get duplicate pageview hits.

    Any suggestions on what I could do to avoid the duplicate pageview hits?

    0
  • Tony Roma

    Hi Sandra,

    I've run into the same problem. I took a class from a very helpful Google Analytics consultancy called LunaMetrics which helped me catch this. They've also proposed a solution:

    If the custom dimension is set at the Session or User level, then you can use an Event instead of a pageview. What the event Category/Action/Label say isn't really important, as we're just using it as a vehicle to get the data into Google Analytics. The important part is the "non-interaction parameter" - which tells Google not to count this as an interaction, which means it won't influence Bounce Rate or Time on Site.

    https://developers.google.com/analytics/devguides/collection/analyticsjs/events

    ga('set', 'dimension1', tag);
    ga('send', 'event', 'ZenDesk', 'UserType', tag, {
    nonInteraction: true,
    });

    I'll update my suggestion above to include this parameter.

    0
  • Sandra Weigl

    Hi Tony,

    I just got the same reply in the Google Analytics user forum :) I updated the code in my post above as well.

    I changed the code in JS but I can no longer report on the custom dimensions in Behavior > Site Content. Instead, I can then add the CDs to the statistics in Behavior > Events.

    Is this how it is supposed to be? Does this mean I can't really combine the statistics before and after changing the custom dimensions to event hits?

    Thanks,
    Sandra

    0
  • Tony Roma

    Hi Sandra,

    I guess we're on the right track. :) Ours is a User-level metric, so I believe it will be applicable across reports through segmentation. Once we've updated our code and answer a couple more questions, I'll update this comment to let you know what happens for us.

    Thanks for sharing your experience, too!

    0
  • Tony Roma

    Hi Sandra,

    Just getting back to metrics after focusing on my main responsibility as Insightly's product writer for a bit. (The Many Hats situation of life at a start-up!) Our custom dimension is available in the Site Content reports and others. And our pageview counts have normalized, so this worked for us.

    I hope you worked it out.

    0
  • OT

    I want to use the exact example in this article, ie tracking based on user role.  Does anyone have a corrected script for this that doesn't break everything?

    Thanks!

    0
  • Corrin Duque

    I also need the correct code for the exact example in this article as using the one given broke our java script.  

    I have a Zendesk ticket out on this as I had to remove the script due to the unwanted impact of the presence of the script causing the Submit button on the customer's request page to disappear.

    We truly need to be able to measure user role in our Google Analytics so would be grateful for the functional script!  Thanks!

    0
  • Corrin Duque

    I received an update from Zendesk that this article references an old legacy code.  The following articles were provided to help modify using the new code Google supports:

    https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs

    https://developers.google.com/analytics/devguides/collection/analyticsjs/

    0
  • Jessie Schutz
    Zendesk Customer Care

    Hi Corrin! Thanks for coming back and sharing what you found out from Support. I'm going to follow up on this Tip to see if we can get it updated.

    0
  • Corrin Duque

    Thanks so much Jessie!  I'm a novice with java script so the update will be truly appreciated!

    0
  • Corrin Duque

    Adding the final comment from Zendesk support pointing to the resources for updating this script.  As a novice in java script I am not able to create the script based on the instruction and shell alone.  Hopefully this provides all that is needed to update this article as this is a valuable information perspective to capture:

    "As you can see here the use of the _gac object has been deprecated by Google and is something that we don't load in Help Center. Thus, when you utilize this old code, the JavaScript on the page fails as _gac is undefined as seen here. When this exception occurs all JS on the page fails to run, and it is necessary for the JS on the page to run as you have a theme that relies of JS to show the Submit button once someone clicks into the comment area.

    Thus, to continue using what you were using I recommend you use the new code that Google supports which can be found here.

    The new tracking uses the following syntax ga('send', 'pageview');, you can find more info about transition from the old code to the new in this Google article.

    Once you have the proper (new) Google Analytics code in place and no JS fails on your Help Center, you should not have the issue you were experiencing earlier.

    I can provide some guidance regarding this, however please not that I'm not versed in Google Analytics.

    As the old ga.js is legacy code and can still be used I would first try to see if pasting the code found here and replacing UA-XXXXX-X with your web property ID, resolves the issue for you. You can paste this code in the Document Head section of your Help Center. This would be the easiest way for you to get things working as it was. However, please note that this may break in the near future.

    If you would like to migrate to the new Universal Analytics by Google Analytics you'll have to make some backend changes in your Google Analytics as stated here. The Custom Variables found on the old platform has been changed to Custom Dimensions. As you can see the generic code for custom dimension is ga('set', 'dimension1', 'Paid');, if you compare this to the old ga.js it's as follows:

    I hope this helps you out get started with getting things working for your Help Center and Google Analytics again."

    0
  • Jennifer Rowe
    Zendesk Documentation Team

    Hi Corrin!

    Thanks for reporting back and providing this detailed info! We're going to work on updating the article.

    thanks!

    0
  • Corrin Duque

    Thanks Jennifer!  Excellent news!  I look forward to being able to leverage this!

    0
  • Corrin Duque

    Any news on updating this so we can track user role in site search?

    0
  • Jennifer Rowe
    Zendesk Documentation Team

    Sorry, Corrin, but I don't have good news here. I haven't been able to find anybody who can update this one...yet... 

    0
  • Corrin Duque

    Thanks Jennifer,

    We are unable to pull a report on solely customer or soley agent site search activity currently.  I signed up for early access to explore so haven't seen more than a demo of BIME Analytics.  Are you aware of whether we will be able to pull a high level Customer vs Agent site search trends via Explore?

    0
  • Jennifer Rowe
    Zendesk Documentation Team

    Hi Corrin,

    I'm not sure about the specific HC reports that will be in Explore. The two teams are currently in the process of planning those out. But I expect that the first version of the dashboards might be more focused on content and not that type of user segmentation. If you want to check back in mid-January, I might know more them.

    0
  • Jennifer Rowe
    Zendesk Documentation Team

    Hi Corrin and Happy New Year!

    Just wanted to let you know that this article was updated! 

    0
  • Corrin Duque

    Thanks Jennifer and team for updating!  This is indeed a Happy New Year gift!

    I've followed the instructions and tested to ensure it no longer breaks the java script and will wait a few hours to see if results start populating.

    Question on the article.  Is there a place we should be adding the javascript detailed out by the Google Analytics custom dimension referenced in step 2?


    Or do we only need to add the javascript as indicated in step 3?

    0
  • Corrin Duque

    I believe my question was answered by the results!  Even though the article does state "It may take an hour or so for the new custom dimensions to be available in your Google Analytics project" I expected to see them a bit sooner.  

    In logging out and back in several records suddenly populated.

    So entering only the JS code indicated in step 3 worked great.  I suppose the Google Analytics example is for other platforms.

    Thank you again for updating!

    0
  • Jennifer Rowe
    Zendesk Documentation Team

    That's great news! Thanks for reporting back, Corrin!

    0
  • Peter Rush

    A question about user role - I was expecting to see the role value correspond exactly to the "Role" user field in the app.  However, it appears that users with "Administrator" role in the app don't have HelpCenter.user.role = "Administrator".  It's "Manager".

    Can anyone confirm the ZenDesk logic here for how actual user roles in the app map to HelpCenter.user.role in JSON?

     

    Thanks!

     

    0
  • Ryan McGrew
    Zendesk Product Manager

    Hey @Peter,

    You're correct that this is a bit of legacy of the Zendesk product evolving over time. Many times when we update user facing labels in code, the internal representation in the database and other systems doesn't necessarily get the same update to avoid any unforeseen consequences. Additionally a few other roles can have admin privileges like Team Leader or a user with the Help Center Manager permission.

    There are 4 possible values in the context of HelpCenter.user.role

    "manager", "agent", "end_user", "anonymous"

    Let me know if that answers your question.

    0
  • Peter Rush

    Hi Ryan - thanks for the quick response.  Can you provide a table showing how the standard user roles in the interface map to the JSON values in session?

    Like this...

    Administrator >> Manager

    Agent >> Agent

    etc

    0
  • Ryan McGrew
    Zendesk Product Manager

    Hey Peter,

    That will depend on your user roles and your account plan level. If you have created custom roles on Enterprise, any role with the Help Center Manager role will be reported as "manager".

    You can see more here: https://support.zendesk.com/hc/en-us/articles/203662026-Creating-custom-roles-and-assigning-agents-Enterprise-

    But based on the predefined Enterprise roles, you would have:

    • Legacy Agent - "agent"
    • Light Agent - "agent"
    • Staff - "agent"
    • Team Leader - "manager"
    • Advisor - "agent"
    • Administrator - "manager"

    End user is anyone that has a log in but is not an agent or manager. Anonymous is anyone browsing your Help Center while not logged in. I hope this helps.

    Thanks!

    0
  • Dan McDade

    I wanted to include user.id in what I am sending to google analytics, but for some reason it does not seem to be working. I went through the steps listed and created 3 dimensions, the user.role, user.locale, and user.id. I can see the user.role and user.locale being populated but user.id is not. Any reason this might be? 

    //Capture User Role
    ga('send', 'event', 'Help Center', 'User', {

    'dimension1': HelpCenter.user.role,

    'dimension2': HelpCenter.user.locale,

    'dimension3': HelpCenter.user.id,

    nonInteraction: true

    });

     

    Thanks!

    0
  • Dan McDade

    It looks like the reason that HelpCenter.user.id does not work is because it is not available in the javascript object. 

    https://gist.github.com/skipjac/8186753 

    I can see that the HelpCenter.user.identifier is available but this seems like it might be some sort of a hashed id value. Is there any documentation anywhere that I can refer to to understand how this value is hashed to decrypt this value into my user ids?

    0

댓글을 남기려면 로그인하세요.

Zendesk 제공