In part 1 of this series, we discussed how personalization rules can be embedded within Snippets, and where ever those Snippets are added to pages, those personalization rules will execute. This is handy when you are personalizing pieces of global elements such content that appears within main navigation or footers.
In part 2, we introduced the concept of macro personalization and how we can “swap out” Snippets added to a page to personalize the entire Snippet – which is great when you are personalizing more complex items like carousels, tabsets, accordions, or if you wish to change out global elements and literally swap the entire header or footer based on a personalization condition.
So this part gets really interesting.
Using Snippets within Snippets
Snippets can be added into other Snippets 🙂 In doing so, I can also add a macro-personalization embedded within a Snippet.
So here’s our example – we have a mega menu with flyout panels within the website.
I want to swap out the content of the first flyout menu via a personalization rule.
Step 1 – Convert my existing panel contents to a Snippet
First, I will convert the content of the fly out panel to a Snippet using the Snapshot feature within SCORE.
Step 2 – Add the Personalization Condition
This part is just like the second blog article, except that I am defining the macro personalization within a Snippet. I already have another Snippet to swap out the 4 column category selection panel.
Step 3 – Publish and You’re Done
Yea, that’s it. Now I have a personalization that will modify my main menu based on a condition defined by my content author.
First – here’s the default Shop Menu Item…
And now, the new Shop menu item once my personalization condition is met…
So Snippets from Brainjocks, now Perficient, SCORE are not only a significant help to the content author when building and managing reusable site features, they also provide some unique capabilities to the marketer to personalize your Sitecore website using xDB.
What are the performance considerations with personalizing snippets? I know that snippets are usually things we want to cache. We created a Vary by Personalization cache option to help with this, but was wondering what other thoughts you might have.
Hey Curt, you are correct – personalization actually fights caching in all areas – not just in Snippets. If something is cached, it doesn’t go through the rendering pipeline, and therefore it can’t execute the logic to trigger personalization. However, there are two things we’ve done to make this more performant with Snippets. First, in SCORE 3.0 we have worked out a method to make the Snippet extraction and rendering more performant. We do so by caching the rendering XML “pre-rendered”, which allows the personalization embedded to still run during the rendering pipelines. That will release in a few weeks. Second is a method called “donut caching” – where you cache everything that surrounds the personalization / MVT. That is still in “R&D” for us, but we’re planning on implementing that as well.