Applying personalization per host name

Recently, we had a requirement where we needed to personalize content based on the current host.

The requested scenario was: visitor can access the same site from different hosts. For example: pension.company.nl, insurance.company.nl, mysafety.company.nl. Based on the current host, the visitor should see a different icon and text on the page.

How did we meet this requirement?

Add multiple site configure per host

As each host pointed to the same site in the Sitecore content tree, we decided to add multiple site configuration entries per host. They all pointed to the same root path and start item, but had different host names and site names.

To learn more about how to configure an extra Sitecore website, I suggest you reading Configure multiple managed websites.

Below you find how our configuration looked like:

Sitecore determines the site context based on the incoming URL and the hostName and virtualFolder attributes. In the article Determining website context from Sitecore documentation you can find more information about it.

Knowing the context site, we can create conditional rules based on the site name defined in the configuration above. As we don’t want to repeat the conditional rule every time we add some personalization we can create predefined rules.

Create predefined rules for each site

To add personalized content, you to need to configure a detailed condition on the component. You might have to personalize content in multiple locations on a page, or multiple locations across pages that need to use the same set of conditions. Sitecore covers this type of scenario. Rather than recreating the conditions in each location, you can create a predefined condition once, which you can then reference in multiple locations.

Following our approach, we created a few predefined conditions so we could reuse them in our personalization. In order to create predefined conditions, do the following:

  • In the Launch Pad, click on Marketing Control Panel icon.
  • Next, in the Content Tree, navigate to /Marketing Control Panel/Personalization/Predefined Rules.
  • Right click the Predefined Rules folder and add three new Conditional Rendering Rules. Name them according to the following: Site is Pension, Site is Insurance, Site is My Safety.

Here is how your content tree should look like:

In the Create Rule dialog, select the condition where the site name is equal to and then use the same site name as defined in the configuration file.

If you want to learn more about predefined conditionals, I suggest you reading the blog post Personalization and Predefined Conditions in Sitecore by Grant Bartlett.

Apply the personalization per host/site

Finally, we used the Conditional Rendering Rules that we created and applied the personalization in the content. Below is the Personalize the component dialog box that opens when you personalize the content.

Credits

Photo by Hope House Press – Leather Diary Studio on Unsplash.

comments powered by Disqus