Einstein Activities for Phased Headless Rollouts
Reports & Dashboards analytics can only be derived from either web adapter logs included automatically with SFRA or SiteGenesis or from the Einstein Activities API.
If you are pursuing a phased headless rollout, where some site elements are powered by PWA Kit and others are powered by SFRA or SiteGenesis, and you want to use Reports & Dashboards across your entire site, you must update your SFRA implementation to use the Einstein Activities API.
This guide shows how you to implement the Einstein Activities API in SFRA's checkout.
Use caution when integrating the code examples provided, and always test your code thoroughly before pushing it to production.
Lines to be added to existing code are marked with the addition (
+) symbol and lines to be deleted are marked with the subtraction (
Start by updating your checkout controller to include the current basket ID.
Update the ISML template used for checkout. This change makes the basket ID, items, and total available to the browser.
js/einsteinHelpers.js that contains helper functions:
Don’t forget to replace the placeholders
<YOUR_CLIENT_ID> with actual values.
checkout.js script to record activities. You must add this call to
require() at the top of your checkout script, and it must appear after any existing imports.
beginCheckout activity at the end of the
initialize function for your checkout code:
The activity is only triggered one time per page load during checkout. Activity data preparation is handled automatically.
checkoutStep activity when the checkout stage is changed. Append the following code to the
checkoutStep activity in the
updateUrl method ensures that any transition from one checkout stage to the next (or previous) is tracked.
That’s it! You’ve successfully implemented Einstein Activities for checkout.