exdst / jss-astro-public

Sitecore JavaScript Software Development Kit for Astro
Apache License 2.0
20 stars 2 forks source link

Sitecore Personalize Middleware #30

Open mksby opened 3 months ago

mksby commented 3 months ago

What's the best way to add Sitecore Personalize support for @astro-sitecore-jss/create-astro-sitecore-jss? It should interact with CDP to create page variants.

Antonytm commented 2 months ago

@mksby

The current version doesn't support Sitecore Personalize.

But that is possible to add it:

  1. First of all, you will need to run Astro in SSR mode: https://docs.astro.build/en/guides/server-side-rendering/ (otherwise, you will not have the context of the current user to personalize)
  2. Add Engage SDK package, it should be similar to Next.js https://doc.sitecore.com/cdp/en/developers/api/integrate-engage-sdk-nextjs-server-side.html
  3. Create a component that will also include the SDK package for the client side, similar to https://doc.sitecore.com/cdp/en/developers/api/integrate-engage-sdk-nextjs-client-side.html#verify-that-sitecore-cdp-captured-your-view-event