Help Limiting Content Based on User Segment | Community
Skip to main content

Help Limiting Content Based on User Segment

  • October 4, 2019
  • 4 replies
  • 0 views

I am wanting to limit specific content on the homepage based on user segment.

 

I do this based on tags in a different area by using this javascript:

    var userTags=HelpCenter.user.tags;
//check if any tags are returned. If no tags defined, print to console.
if (userTags.length!=0)
{
//if tags are found, start iterating through using a for loop.
for(var i = 0; i < userTags.length; i++ )
{
//check for the require tag.
if (userTags[i] === 'emergencycontact')
{
//unhide link
$('div.emergencylink').show();
$('div.nopostrights').hide();
}
}
}
});


Anyone have thoughts on how I can achieve something similar for an organization or user segment? I really don't want to manually tag 325 users.

4 replies

Trapta
  • October 5, 2019

Hi 13682554307,

You can use the same code replacing HelpCenter.user.tags with HelpCenter.user.organizations and check for the organization instead of tags.

Currently, there is no way to do this using Zendesk HelpCenter Components so one has to use the JS code in order to achieve something like this.

Let me know if this solves your issue.

Thanks


  • October 6, 2019

Thank you, Trapta!! That did it. 


  • November 26, 2019

Perhaps someone could help on this?  For HelpCenter.user.organizations[0].name, it will only break the js if there is no organization that a user belongs to.  I've tried all sorts of looking for length like the above example and it breaks when a user does not have an organization.  Any help would be appreciated.

Thanks so much.

- Michael


Brett13
  • Community Manager
  • December 9, 2019

Hey Michael,

It looks like you haven't received a response on this post. I'm rather limited on what I can assist with from my end, but I did want to double-check with you to see if you're still running into the same issue.

If so, any chance you could provide the code you're using so far? This may help other community members get a better understanding so they can assist further.

Thanks!