Custom Personalization Rules in Sitecore 9

Personalization allows you to deliver the target the component in which your visitor showing interest. For example, visitor visits or browse specific product feature, specification, details, etc. on website. So, you show personalized content to the visitor on the bases of his previous behavior on the website.

You can create personalization rule on bases of The goal, Campaign, custom facet, etc. Your website will respond to the bases of above-defined rules and display or hide specific component or change its behavior.

To start with custom personalization, you need to perform the below steps:

Step 1:   Go to the path “ /sitecore/system/Settings/Rules/Definitions/Tags ” right-click on Tags and add new customize Tag (I have given a name CustomPersonalization):


Step 2:    Go to the path “ /sitecore/system/Settings/Rules/Conditional Renderings ” and expand conditional rendering and add created tag into the Tags property of the default tag as below:


Step 3:  Go to the path “/sitecore/system/Settings/Rules/Definitions/Elements
  ·    Right-click on Elements and add new Element folder (I have given the name CustomPersonalization).
  ·    Right-click on CustomPersonalization and add a new condition and set the Text and Type property of condition.
·       Text property: Give the condition with the rule which will show to the content editor.
·       Type Property: Specify your class name with a namespace followed by the assembly name, where you will write your personalization rule business logic.


Step 4:   Now you need to add created tag into default tag, Tags property of element folder:


Step 5:   Write your personalization rule business logic as below or update your code as per requirement:

public class PersonaliseRuleService<T> : StringOperatorCondition<T> where T : RuleContext
    {
        public string Value { get; set; }
        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            HttpCookie customCookie = HttpContext.Current.Request.Cookies["Custom_Personalization"];      
     if (Value.ToLower().Equals(customCookie.Value.ToLower()))
            {
                return true;
            }
            return false;
        }
    }
Step 6:   After completion of all the above change, you need to set our personalization rule on the component using experience editor. Go to the page presentation details and select that rendering and click on personalize section. Add your personalization rule and select Edit rule then select your created rule and update the data source from the content property.




Same you can create a more custom rule to show relevant content to the visitor.

Happy Sitecoreing 🌝

Comments

  1. nice informative post. Thanks you for sharing.
    NodeJS Development

    ReplyDelete
  2. Website personalization solution empower businesses to tailor content based on visitor behavior, enhancing user experience and engagement. In Sitecore, customizing personalization involves defining rules, adding tags, and setting conditions. By implementing personalized rules and logic, website components dynamically adjust to visitor preferences, ensuring a responsive and engaging user journey. This step-by-step guide facilitates the creation of custom personalization rules, enriching the website's functionality and optimizing content delivery for enhanced user satisfaction.

    ReplyDelete

Post a Comment

Popular posts from this blog

Sitecore Installation Error: Failed to Start Service 'Sitecore Marketing Automation Engine'

Import CSV Data in Sitecore Using PowerShell: Part-3

Sitecore Technology MVP Journey 2022