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.
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.
Once inside Experience Explorer, on the left side you should see an arrow. Under the Experience
tab you should see a list of Presets.
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.
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.
Once the user is created, we can then associate it to our Preset.
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.
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.
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.