Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
You can use personalization in Magnolia without writing any Java code by using the cookie trait.
This page and its subpages explain the cookies trait and how to use it to suit your site. Tutorial: Creating a custom cookie trait provides an example custom cookie trait and takes you through the process of creating, setting and using custom cookies.
Magnolia provides the cookie trait out of the box. The trait is part of the Personalization module. You can use this trait for just about any kind of personalization feature.
Magnolia's cookie trait
Magnolia's cookies trait reads data from cookies with the and uses the to render the appropriate content variation according to configuration.
All required classes for the cookie trait are part of the magnolia-personalization-traits submodule which is installed with the Personalization module. The cookie trait supports multiple cookies. You can configure as many cookies as you like for multiple use cases and use them simultaneously.
What is a cookie?
A cookie is a text file containing information about a specific website visit that is kept by the browser on the user's computer. When the browser next requests a page on the website, it sends the file to the web server. Cookies allow you to record visitor information and serve targeted content based on them. The information is stored in a browser cookie.
Session cookies last only as long as a user is on a website and expire when the browser window is closed or the session times out. Persistent cookies (a.k.a tracking cookies) remain active for a period of time and are used whenever the website is accessed.
Cookie traits in Magnolia demo
This video provides an overview of how cookies work and demonstrates how the
tourType cookies is used on the Travel demo to serve personalized content based on a user's tour type preference.