Hiding components from users when they are not logged in. AKA Personalisation and you!

Hiding components from users when they are not logged in. AKA Personalisation and you!
When you first install Sitecore 7.2 this is the page that greets you:
Sitecore 7.2 Home Screen

However for this example, let’s make it so that users that aren’t logged in can’t see the title and body, until they are logged in they shouldn’t be welcomed to our system.
While this is a silly example, the same mechanism can be used to achieve many other requirements, such as show specific content based on the users location, goals that have been set, or perhaps hiding welcome content after they have already used the website.
To make this even better, the rules engine is easily customised such that you can create custom rules based on applicable business requirements such as if the user has a certain attribute in their profile.

  1. Firstly, we need to make sure that analytics are enabled, personalisation is driven through the analytics engine and requires it to be turned on
  2. Log into Sitecore, go to the content editor and select the Home item.
  3. In the menu select Presentation and Detailssc72-presentation-details
  4. Under Sample Layout select editsc72-layout-edit
  5. In the Device Editor select Controls, then Sample Rendering and click Personalize.sc72-device-editor-personalise
  6. In the Personalize the Component window click New Condition
  7. Name the condition “Hide for Anonymous”
  8. Under the “Hide for Anonymous” condition click Editsc72-personalize-the-component-hide-edit
  9. In the rule editor, find the Security rules and click on “where the current user is anonymous” and click ok.
  10. Back on the Personalize the Component window to the right of where we clicked edit, check the “Hide Component” tick box.sc72-personalize-the-component-hide-with-rule
  11. Publish the home item.

If you open an incognito window or clear your cookies and go to the home screen you will get this cold unwelcoming page:
sc72-no-welcome

NOTE: To quote the great Stan Lee “With great power there must also come- great responsibility”, whilst the rules engine allows you to tailor content you must be careful to not over personalise and create content that is never seen because you have too many rules chained together or have catch all rules.

Now go forth, create custom rules and amazing websites.

Leave a Reply

Your email address will not be published.