diff --git a/examples/pixel/README.md b/examples/pixel/README.md index b085292..607743a 100644 --- a/examples/pixel/README.md +++ b/examples/pixel/README.md @@ -1,8 +1,8 @@ # Bloomreach - Pixel instrumentation example -This example demonstrates how to instrument pixel across a simple storefront. +This example demonstrates how to instrument the pixel across a simple storefront for page view, widget view, suggest, search, click, add to cart and conversion events. -- See `src/config.js` file to configure it to run for your account and catalog +- See `src/config.js` file to configure it to run for your account and catalog. This also has the configuration to turn on debug mode for the pixel - See `src/hooks/useAnalytics.js` file to see how the pixel events are formatted - Search for the term `trackEvent` to see how the pixel events are instrumented across the sourcecode - Note: On codesandbox, because of how the preview is rendered in the iframe, the pixel script is not able to set the `_br_uid_2` cookie on the right domain, so you will not see the cookie sent in the pixel events. For the cookie to be set and sent in the pixel events, open the codesandbox preview in a new tab or run the example locally diff --git a/examples/pixel/src/app/DeveloperToolbar.jsx b/examples/pixel/src/app/DeveloperToolbar.jsx index 0e91da9..c71982e 100644 --- a/examples/pixel/src/app/DeveloperToolbar.jsx +++ b/examples/pixel/src/app/DeveloperToolbar.jsx @@ -68,7 +68,7 @@ export function DeveloperToolbar() { - {eventsCount} + {eventsCount > 25 ? '25+' : eventsCount} diff --git a/examples/pixel/src/app/cart/page.jsx b/examples/pixel/src/app/cart/page.jsx index 43f8e37..403e99f 100644 --- a/examples/pixel/src/app/cart/page.jsx +++ b/examples/pixel/src/app/cart/page.jsx @@ -6,16 +6,14 @@ import { Button, MinusIcon, PlusIcon, TrashIcon } from '@bloomreach/react-banana import { useIntersectionObserver } from 'usehooks-ts'; import { useEffect, useState } from 'react'; import useCart from '../../hooks/useCart'; -import useRecommendationsApi from '../../hooks/useRecommendationsApi'; import { similar_products_widget_id } from '../../config'; -import { ProductsCarouselWidget } from '../../components/ProductsCarouselWidget'; -import { CONFIG } from '../../constants'; + +import { ItemBasedRecommendationsWidget } from '../../components/ItemBasedRecommendationsWidget'; export default function Page() { const router = useRouter(); const { cart, incrementItem, decrementItem, removeItem, cartCount, cartTotal } = useCart(); - const [recOptions, setRecOptions] = useState({}); - const { data: similarProducts } = useRecommendationsApi(similar_products_widget_id, CONFIG, recOptions); + const [recPids, setRecPids] = useState([]); const [ref, isIntersecting] = useIntersectionObserver({ threshold: 0, root: null, @@ -23,12 +21,7 @@ export default function Page() { }); useEffect(() => { - setRecOptions({ - item_ids: cart.map((item) => item.id).join(','), - filter: `-pid:(${cart.map((item) => `"${item.id}"`).join(' OR ')})`, - rows: 4, - start: 0, - }); + setRecPids(cart.map((item) => item.id)); }, [cart]); return ( @@ -116,8 +109,13 @@ export default function Page() {