Handle Cookie Restrictions
Both Adobe Commerce and Magento Open Source ask for consent before data is stored in browser cookies. For more information, refer to Cookie restriction mode.
How Product Recommendations handle cookie restrictions
When you deploy the magento/product-recommendations
module to production, it begins collecting shopper interaction events on your storefront. This data can be stored in browser cookies or local storage to power recommendation algorithms.
Data affected by cookie restrictions
The following Product Recommendations data is not collected when cookie restriction mode is enabled:
- Behavioral data: Product views, add-to-cart actions, purchases, and other shopper interactions.
- Session data: Shopper session information and recommendation unit interactions.
- Personalization data: Data used for recommendation types like “Recently viewed” and “Most purchased”.
Impact on recommendation types
When cookie restriction mode is enabled and shoppers haven’t accepted cookies, certain recommendation types may not display or may show limited results:
- Recently viewed products: Requires session data stored in cookies/local storage.
- Recommended for you: Requires behavioral data for personalization.
- Bought this, bought that: Requires purchase history data.
Third-party cookie consent solutions
Product Recommendations may not automatically integrate with third-party cookie consent solutions. It is the merchant’s responsibility to ensure that data collection complies with applicable privacy laws and regulations.
If you use a custom cookie consent solution, you can implement the do-not-track cookie mechanism to control data collection.
Implementing do-not-track cookies
You can use the mg_dnt
cookie to programmatically control data collection:
Cookie name
const DNT_COOKIE = "mg_dnt";
Disable data collection
Set the do-not-track cookie when users decline cookies:
$.mage.cookies.set(DNT_COOKIE, true);
Enable data collection
Clear the do-not-track cookie when users accept cookies:
$.mage.cookies.clear(DNT_COOKIE);
Testing cookie restriction mode
To test how Product Recommendations behave with cookie restrictions:
- Enable cookie restriction mode in your Adobe Commerce configuration.
- Visit your storefront without accepting cookies.
- Verify that recommendation units display appropriate fallback content.
- Accept cookies and verify that recommendations begin collecting data.
Privacy compliance
Product Recommendations data collection does not include personally identifiable information (PII). All user identifiers, such as cookie IDs and IP addresses, are anonymized. For more information, see the Adobe Privacy Policy.