Cookie Based Sitecore Rule Conditions

A common usage scenario in Sitecore renderings is when we want to show/hide a rendering based on cookie condition. Think of a temporary banner suggesting user about storing cookies on their machine. Or probably directing the users to have a peek on an upcoming company portal.

Traditionally we will create our rule conditions and use them to customize renderings. Did this multiple times. But never stored the knowledge in a module or so. Though this code need not be a module of its own, having this as module will simple save time for someone.

I was searching for an example of cookie condition and found this link below.
http://sitecoreskills.blogspot.in/2014/03/cookie-based-sitecore-rule-conditions.html

So, with this information, I thought will create a sitecore package that is reusable (Package Uploaded to market place. Pending for review.). Created my classes based on the above link. With these new rules, created my conditions under /sitecore/system/Settings/Rules/Definitions/Elements

Assuming my work is completed I headed to a test page where I can see cookie conditions for personalization. But here is the bummer as I couldn’t find my conditions at all when I added a new condition and opened the ruleset editor. I am using Sitecore.NET 8.0 (rev. 150223)



So here is a puzzle for me to solve. Where are my conditions?. So, I thought to look into Rule Engine cook book. Just couple of google searches resulted few articles explaining the details on changes took place from Sitecore 7.2. Here is the link with clear steps explaining how to register new rules in Sitecore 7.2+ and display in ruleset editor.

http://www.sitecore.net/learn/blogs/technical-blogs/getting-to-know-sitecore/posts/2013/11/limiting-conditions-and-actions-with-sitecore-71.aspx

Back on track, performed the steps suggested in the post with few changes

1. Didn't create any item under "/sitecore/system/Settings/Rules" using "/sitecore/templates/System/Rules/Taxonomy/Rules Context Folder" template
2. Created new element iMadd-Cookies element folder under "/sitecore/system/Settings/Rules/Definitions/Elements/"  and added conditions to it.


3. Created a new tag under /sitecore/system/Settings/Rules/Definitions/Tags/iMadd-Cookies


4. Added the tag created in step#3 to Tags multi-list field under Taxonomy Section under the highlighted path in screenshot below.


5. In the final step, add a new Tags Definition under /sitecore/system/Settings/Rules/Conditional Renderings/Tags as shown below.



Select correct Tags for Taxonomy section.
With the above steps the new cookie conditions will display in conditional renderings rule set editor.






Comments