SaaS CMS has officially launched! Learn more now.

API to find out if content has visitor groups configured?


Is there an API or way to understand whether a piece of content is configured with visitor groups ?

I don't care what those groups are or whether an http request would match any of those groups. I just want to find a way of knowing whether content properties are personalised (ie, content areas, or rich text blocks)

Apr 04, 2019 13:59

Hi Mark,

You could loop through the properties on the content and check whether each property is of type IPersonalizedRoles and, if so, check whether there are any roles defined using .Roles(). If it's not an IPersonalizedRoles, check if it's a ContentArea and, if so, check if any of its items have the ContentGroup set. Something like this:

var isPersonalised = myContent.Property.Any(p => ((p as IPersonalizedRoles)?.GetRoles().Any() ?? false) || 
    (((p as PropertyContentArea)?.Value as ContentArea)?.Items?.Any(x => !string.IsNullOrEmpty(x.ContentGroup)) ?? false));


Apr 04, 2019 15:19

You can use the Visitor Group Usage Viewer and check the source code ;): 

Edited, Apr 04, 2019 16:58

To be fair, that's the post that introduced me to the IPersonalizedRoles interface.

Apr 04, 2019 19:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.