7

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!

  • Do you use the _StandardValue for setting the datsource for this component? – Artsem Prashkovich Dec 5 '17 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 '17 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. – Stein Peeters Dec 5 '17 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? – Stein Peeters Dec 5 '17 at 14:16
  • Seems similar to your problem @Stein pageditor.wordpress.com/2014/11/21/… – Diego Dec 5 '17 at 14:33
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.

-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.

  • I couldn't figure out how to apply the pre-defined rule to the component in Marketing Control Panel? Could you explain that? – Chandra Sekaran V Aug 20 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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