Help Center user segmentation using Google Analytics custom dimensions

40 Comentarios

  • Ryan McGrew
    Zendesk Product Manager

    Hey Dan!

    This identifier is actually a 1 way sha1 hash of the user id so you can't decrypt it. However, you could potentially user the email address in the user object for this. That should be a unique identifier for the user.

    You can also use the API endpoint /api/v2/users/me.json to get the current user information, including id.

    Thanks!

    0
  • Ryan McGrew
    Zendesk Product Manager

    I just realized the below comment won't work. Please disregard

    ***

    I also just realized that we also have the user object in the template that you could use as well to assign a variable in JavaScript.

    *** 

    Thanks!

    0
  • George Panoschi

    Hi, could anyone help me make a segment from a website that is not structured with " / " ?

    0
  • Bill Cicchetti

    Resurrecting this article.

     

    So I am trying to create a custom dimension in GA for user role.

    1) I have GA activated and see out of box reports and dashboards populated.

    2) I added this to the script.js file

     

    //send user role to Google Analytics

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

    });

     

    I went into Chrome DEV Tools and saw no errors.

    3) I logged into GA and create a custom dimension

     

    If this all looks correct  how to I add a criteria to a custom report to filter on end users?

    Do I need a specific value for dimension and filter?

     

     

    0
  • Chris Stock
    Community Moderator

    Hi Bill Cicchetti, you're almost there. The final piece of the puzzle is to create a custom segment that uses the values recorded by your custom dimension.

    You'll see an 'Add Segment' box at the top of most of the GA reporting pages:

    Click on this, then on 'New Segment':

    Then select 'Conditions', under the 'Advanced' heading on the side-panel:

    From there you'll need to search for your custom dimension in the first conditional select menu (mine is called User Role, yours would be userRole):

    Change the operator from 'contains' to 'exactly matches', and then select the value you want to segment (i.e. end_user, anonymous, agent etc.).

    That should be all there is to it.

    0
  • Evan Walker

    Hey there!

     

    I'm trying to get this to work, and I just can't seem to capture the user roles in Google Analytics, when I search it keeps coming up with nothing. I've added a custom segment like the previous comment advised, and when I try to search it still comes up with nothing.

     

    This is the code I've added to the Help Center:

        // GA Custom Dimensions
    var userRole = HelpCenter.user.role;
    ga('set', 'dimension1', userRole);
    ga('send', 'pageview');
     
    });
     
    And this is what the custom definition looks like:
     
     
     
    As you can see, I tried to emulate what the previous successful commenter was able to do, but I'm not getting any results. Can someone assist?
     
    0
  • Catherine Michalak
    Community Moderator

    Hi there,

    Could anyone advise what would be the best way to set up this type of segmentation using user tags?

    User role is good, but user locale isn't useful in our case. Tags however capture various user attributes like country, department etc that I'd love to be able to dissect the data by.

    For example when we see that users search for "bike scheme" with zero search results but do not know from which location, it's difficult for us to make useful changes to content, to address the issue. Being able to break this down by user tag country would be very helpful.

    Thanks

    Catherine

    0
  • Ryan McGrew
    Zendesk Product Manager

    Hey Catherine Michalak,

    Tags are available in JavaScript via the following attribute

    HelpCenter.user.tags

    This is an array of the tags on the user, so it needs to be handled a little differently. Let's say you had dimension1 set to userCountry or something like that. You could then iterate over the set of tags and try to map tags to the dimensions you'd like to set. It might look something like this:

    Array.prototype.forEach.call(HelpCenter.user.tags, function(tag) { 
    var countries = ['germany', 'uk', 'denmark', 'france'];
    if (countries.includes(tag)) {
    ga('set', 'dimension1', tag);
    }
    });
    0
  • Catherine Michalak
    Community Moderator

    Hi Ryan,

    Thanks for this.

    I'm quite new to the coding world and so have some basic questions.

    Which of the values in the above code would i need to replace? Do I need to list out all existing country tags?

    Our user profiles depending on location would have one of these tags for example (country:netherlands, country:united_kingdom, country:spain, etc). We have users in over a 100 countries.

    Thanks

    Catherine

    0
  • Ryan McGrew
    Zendesk Product Manager

    Good questions. So since you have tags set up with country: as the prefix, it'll probably make this a bit easier. Here's how I think this could work in your case:

    Array.prototype.forEach.call(HelpCenter.user.tags, function(tag) { 
    var match = tag.match(/country:(\w+)/);
    if (match) {
    ga('set', 'dimension1', match[0]);
    }
    })

    This would send a value of country:united_kingdom or country:spain as the value of dimension1. This assumes the country name after country: is just letters, numbers and _ characters. I don't know exactly how your tags are structured, so I can't say it'll 100% work. But this should get your started.

    0

Iniciar sesión para dejar un comentario.

Tecnología de Zendesk