Creating custom traits without Java
- Related topics
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.
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.
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.
The DX Core Demo bundle has two example cookie traits:
tourType: Used in the Travel demo to set user’s tour type preference.
weatherLocality: Additional example.
This video provides an overview of how cookies work and demonstrates how
tourType cookies is used on the
Travel demo to serve
personalized content based on a user’s tour type preference.