How To Simulate Sitecore Roles In Experience Explorer

Simulating Roles In Experience Explorer

If you haven't been in Sitecore Experience Explorer in some time, you're probably not alone. As the tool is primarily used for viewing a page and testing personalization rules, it's not a place most people send a lot of their time. Especially when personalization isn't something a lot of websites are taking advantage of.

We recently were asked how an author can simulate users who have different levels of access. This client is using Sitecore internally so users will be browsing the site while logged in through Federated Authentication. As such, each user gets assigned a role.

Let's set it up.

First, Let's Personalize Some Content

Let's say we have some information on a page that we want only to show for a person with a particular Sitecore Role. Let's call that role TOP SECRET. Now using personalization, we can show that content when the rules are met.

Open the Personalize the Component window in Sitecore Experience Explorer

With the personalized content setup, we want to test our our rules to ensure they're running properly.

Next, Let's Visit Experience Explorer

First step is to load up Experience Editor on a page that has personalization. Once loaded, let's go into Experience Explorer via the button in the ribbon as shown below.

Select Explore in Sitecore Experience Editor

Once inside Experience Explorer, on the left side you should see an arrow. Under the Experience tab you should see a list of Presets.

Open Experience Editor on a page that has personalization and open Experience Explorer

These presets are ways we can view the page as other users. There are plenty of other options, but we are going to focus on the Presets.

Because we're doing role based personalization, we need to associate these presets to users in the system. So let's head on over to the Marketing Control Panel.

Let's Create An Experience Explorer Preset

In the Marketing Control Panel head on down to Experience Explorer / Presets. You can insert a Persona Preset. If the insert options doesn't give you that option, you can find it here: sitecore/templates/System/Experience Explorer/Preset Persona.

Once created, if you scroll down to Visitor Information you'll find a field called Associated Sitecore User. This is where we want to select a user from our system that has the roles we want to test with. In our case, we want a user with the TOP SECRET role.

Open the Experience tab to see a list of Presets in Sitecore

Associate A User

Now, while the ability to associate a preset to an existing, real user exists, I highly recommend against it. For two reasons. First, that user's permissions could change and therefore break your ability to test properly (potentially without your knowledge). And second, if you're using something like Federated Authentication with Azure AD, while you might know a user has a certain role, Experience Explorer can't detect it because if the role comes from AD, it's not stored as part of the user profile.

So let's create a test user with the role we want.

Creating a new user preset in Sitecore

Once the user is created, we can then associate it to our Preset.

Creating a test user with the role we to test in Sitecore

Back To Experience Explorer

Now with our test user setup, our preset associated to said test user.

When a normal user is browsing a page we can see that they can't see the personalized content.

After the test role is created, associate it with the preset in Experience Explorer

However, if we switch to the new Preset which is associated to a role with appropriate permission. We see that the personalized content is displayed.

The new preset associated with the test role is now shown personalized content in Sitecore Experience Explorer

Seems rather simple now. However, I know in the beginning it wasn't immediately obvious how to validate a personalization rule based on a role.I hope this short demonstration of how to set it up is makes that less painful going forward.

Hey, Developers!

We're on the look out for talented developers to join our team.

Think you have what it takes?

Meet David Austin

Development Team Lead


David is a decorated Development Team Lead with Sitecore Technology MVP and Coveo MVP awards, as well as Sitecore CDP & Personalize Certified. He's worked in IT for 25 years; everything ranging from Developer to Business Analyst to Group Lead helping manage everything from Intranet and Internet sites to facility management and application support. David is a dedicated family man who loves to spend time with his girls. He's also an avid photographer and loves to explore new places.

Connect with David