10

I have a personalization scenario in which we want to change a component (button label) based on a triggered goal. Not very difficult you would think, but the component exists on all pages. It's impossible to add the personalization rules to each and every page, so I'm looking for a way to implement the rule on component level.

Thank you!

7
  • Do you use the _StandardValue for setting the datsource for this component? Dec 5, 2017 at 12:50
  • this should not be a problem if you are using datasources and each instance of the component is a different instance. Now if you are reusing the same instance for all pages it's not going to work for a single page personalization because it impacts the instance, which is used on all pages...
    – Diego
    Dec 5, 2017 at 12:55
  • @ArtsemPrashkovich I think so, I'm not sure. How do I check this? It's a call to action button in the main navigation of the site. Dec 5, 2017 at 12:57
  • @Diego, I'm not sure. I'm not familiar with this yet. Any way I can check or read about this kind of setup? Dec 5, 2017 at 14:16
  • Seems similar to your problem @Stein pageditor.wordpress.com/2014/11/21/…
    – Diego
    Dec 5, 2017 at 14:33

4 Answers 4

1

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 name CustomPersonalization):

enter image description here

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 default tag as below:

enter image description here

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 new condition and set the Text and Type property of condition.

    Text Property: Give the condition with Rule which will show to the content editor.

    Type Property: Specify our class name with a namespace followed by the assembly name, where we will write our personalization rule business logic.

enter image description here

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

enter image description here

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 above change, you need to set your 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 our created rule and update the data source from the content property.

enter image description here

enter image description here

enter image description here

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

For more details, see Blog Post: Custom Personalization Rules in Sitecore

0

Better if you update datasource of the Component(e.g. Rendering) with a new field of "Rules" type. Create a new template, have a single field with Field Type (Rules) Inherit your datasource's template with this new template.

Now have a Rule placed on your datasource item. and execute it like this way:

public static bool MyRules<T>(this RuleList<T> ruleList, T ruleContext) where T : RuleContext
{
    if (ruleList.Rules != null && ruleList.Rules.Any())
    {
        if (ruleList.Rules.All(x => x.Condition == null))
        {
            return true;
        }
        else
        {
            foreach (var rule in ruleList.Rules)
            {
                if (rule.Condition == null) continue;
                var result = rule.Evaluate(ruleContext);
                if (ruleContext.IsAborted) return false;
                if (result) return true;
            }
        }
    }

    return false;
}

Call it like:

var context = new RuleContext();
datasource.RuleFieldName.MyRule(context);

Now it should decide whether goal is achieved or not. if default rule does not work, do same with some custom Rule and i think it will work.

0

To achieve this component level personalization, You can use standard values of your page template. Please follow the below steps

  1. Create common page template for all pages
  2. Enable standard values for the page template
  3. Add presentation details to the standard values item and add the component where you do the personalization
  4. Now add the personalization rule(based on goal) to the component and assign the corresponding data source item to the component
  5. Once all the above steps are done. Create the page item based on page template which you created in step 1. For Every page item creation, the personalization on component is added automatically. This will ensure there is no need to add personalization on component for each page.
-2

You can use Predefined Rules under the Personalization section of the Marketing Control Panel to configure them and then apply them.

See this thread for more details: Reusing a set of personalization rules?.

Well, instead of answering the question, then I propose this question should be most likely "closed" or marked as duplicate. As the post I referred to includes details and pictures.

That said, having been down voted for not "providing enough details". Here is more details:

Either open the Marketing Control Panel and create/modify the predefined rules there or within the desktop/content editor, go to this path:

/sitecore/system/Marketing Control Panel/Personalization/Predefined Conditions

Create the rule that you need for your component.

Then use the Marketing Control Panel to apply this newly created predefined rule on your component. That will at least reduce the effort dramatically. You do still have to apply the one simple, predefined rule, on the component. But you don't have to recreate the complexity of the rule every time.

1
  • I couldn't figure out how to apply the pre-defined rule to the component in Marketing Control Panel? Could you explain that? Aug 20, 2018 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.