/storefront-next:sfnext-analytics-consentfrom storefront-next
Configures Storefront Next analytics: Einstein/Active Data/Data 360 adapters, consent gating, PageViewTracker, useAnalytics events, and first-touch attribution. Use when wiring engagement adapters, consent banners, or debugging missing analytics events.
Ships in storefront-next. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Events flow: component -> useAnalytics() -> event mediator (@salesforce/storefront-next-runtime/events) -> each registered engagement adapter. Every adapter checks shopper consent before sending. Read docs/README-ADAPTER-PATTERN-GUIDE.md and docs/README-CONSENT-TRACKING.md in your project for the full guides; where they disagree with the code, trust the code (paths below were verified).
| Concern | Location |
|---|---|
| Adapter config | engagement.adapters.* in config.server.ts |
Adapter types, store, hasConsent, buildConsentPreferences | @/lib/adapters (src/lib/adapters/engagement/) |
| Registration of built-in adapters | src/lib/adapters/engagement/register.ts (initializeEngagementAdapters) |
| Built-in adapters | einstein.ts, active-data.ts, data360.ts in the same folder |
| Page view tracking | src/analytics/page-view-tracker.tsx (PageViewTracker, mounted in src/root.tsx) |
| Event hooks | @/hooks/use-analytics, @/hooks/use-tracking-consent |
| Attribution | src/lib/attribution.ts, @/hooks/use-attribution, src/middlewares/attribution-forwarding.server.ts |
// config.server.ts
engagement: {
adapters: {
einstein: { enabled: true, consentCategory: 'analytics', host, einsteinId, realm, siteId, isProduction: false,
eventToggles: { view_page: true, view_product: true /* ... */ } },
data360: { enabled: true, consentCategory: 'analytics', appSourceId, tenantId, siteId, webStoreId: 'sfnext', eventToggles: { /* ... */ } },
activeData: { enabled: true, /* see config.server.ts */ },
},
analytics: {
trackingConsent: { enabled: true, defaultTrackingConsent: TrackingConsent.Declined,
consentCategories: ['necessary', 'analytics', 'marketing', 'personalization'] },
pageViewsBlocklist: [/* paths that must not emit view_page */],
},
}
enabled: false.consentCategory: 'analytics' sends nothing unless 'analytics' is in trackingConsent.consentCategories.eventToggles turns individual event types on or off per adapter. Data 360 ships only view/impression events enabled.einstein and data360 adapter blocks, and activeData.enabled / activeData.eventToggles, are protected config paths and cannot be overridden with PUBLIC__ env vars; edit config.server.ts and rebuild. Other keys follow the PUBLIC__app__engagement__... pattern (see storefront-next:sfnext-configuration).import { useAnalytics } from '@/hooks/use-analytics';
const { trackViewProduct, trackCartItemAdd } = useAnalytics();
useAnalytics returns trackViewPage, trackViewProduct, trackCartItemAdd, trackCheckoutStart, trackCheckoutStep, trackViewSearch, trackViewCategory, trackClickProductIn{Category,Search,Recommender}, trackViewRecommender, search-suggestion and wishlist trackers. On the server these are no-ops, so call them from effects or event handlers. Check the hook source for exact argument shapes before calling.
Consent is read from the auth session (dw_dnt cookie) by useTrackingConsent(), converted to a ConsentPreferences array by buildConsentPreferences(trackingConsent, consentCategories, isTrackingConsentEnabled), and passed to every adapter. While consent is undetermined or declined, no events are sent.
import { useTrackingConsent } from '@/hooks/use-tracking-consent';
import { TrackingConsent } from '@/types/tracking-consent';
const { shouldShowBanner, setTrackingConsent } = useTrackingConsent();
setTrackingConsent(TrackingConsent.Accepted);
Granular per-category consent (for example from a CMP) means replacing the binary banner logic that feeds buildConsentPreferences; adapters already gate per consentCategory.
See references/CUSTOM-ADAPTER.md. In short: implement createMyAdapter(config): EngagementAdapter using hasConsent, register it with addAdapter('my-adapter', ...) inside initializeEngagementAdapters, and add engagement.adapters.myAdapter config (the config type allows extra keys).
A first-touch dw_attribution cookie captures allow-listed landing/referrer params (see LANDING_PARAM_ALLOWLIST in src/lib/attribution.ts). attributionForwardingMiddleware forwards it on order creation. Add a parameter by extending the allowlist; cookie size is capped (MAX_ATTRIBUTION_COOKIE_VALUE_LENGTH).
'analytics' missing from consentCategories, adapter enabled: false, or the path is in pageViewsBlocklist. Startup logs a warning when consent categories are empty.initializeEngagementAdapters, or eventToggles[eventType] is falsy.storefront-next:sfnext-security.storefront-next:sfnext-configuration - config.server.ts, env overridesstorefront-next:sfnext-security - CSP for analytics endpointsstorefront-next:sfnext-authentication - session/cookies behind dw_dntstorefront-next:sfnext-testing - testing adapters and hooksstorefront-next:sfnext-seo - page metadata and structured dataWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin storefront-next25 skills in this plugin
/sfnext-accessibilityBuild and fix accessible UI in a Storefront Next storefront (WCAG 2.1 AA): jsx-a11y lint findings, missing accessible names and labels, form error association, dialog focus management, aria-live status messages, keyboard behavior, color contrast, and verifying fixes with Storybook a11y/play() tests and the e2e axe scan with its baseline. Use for "accessibility", "a11y", "WCAG", "screen reader", "aria-label", "focus trap", "axe violation", pnpm lint:a11y, pnpm a11y, a11y-baseline.json, skip-a11y, STORYBOOK_A11Y_TEST_MODE, or an accessibility audit finding to fix. Do not use for general lint/typecheck gates (use `storefront-next:sfnext-quality-gates`), writing non-accessibility tests (use `storefront-next:sfnext-testing`), or color/token design (use `storefront-next:sfnext-theming`)./sfnext-authenticationWork with Storefront Next's server-only authentication and session architecture (SLAS guest/registered tokens, httpOnly cookies, auth.server.ts middleware). Use for getAuth, useAuth, updateAuth, destroyAuth, protecting account routes, login/logout actions, guest-to-registered basket/wishlist merge, "session expired" redirects, 401 recovery loops, cc-at/cc-nx/usid/dwsid cookies, cookie names or expiry, passwordless login, social login, OTP email verification, passkeys, guest order lookup, or refresh-token lifetime settings. Do not use for Turnstile, CSP headers or cookie-domain config (use `storefront-next:sfnext-security`), calling SCAPI clients (use `storefront-next:sfnext-scapi`), or sharing sessions with SFRA (use `storefront-next:sfnext-hybrid-storefronts`)./sfnext-commerce-featuresCatalogue and router for optional Storefront Next commerce features: Shopper Context (qualifiers, source codes), Order Management returns/cancel/tracking (SOM/OMS), delivery estimates, feature stubs (@feature-stub), guest order lookup, the app_storefrontnext_base email cartridge, and the shipped extensions (bnpl, bopis, multiship, store-locator, ratings-reviews, customer-preferences, product-content, shipping-delivery, theme-switcher). For each: which flag, SLAS scope, Business Manager setting, cartridge, or extension registry entry it needs, and which in-project doc to read. Use when asked how to enable a feature, why a feature does not render, what prerequisites a feature has, or which stubs are mock data. Do not use for building a new extension (use `storefront-next:sfnext-extensions`), config loading (use `storefront-next:sfnext-configuration`), or SLAS login flows (use `storefront-next:sfnext-authentication`)./sfnext-componentsBuild and modify UI components in a Storefront Next storefront: page components with Suspense and use()/Await, createPage and withSuspense, Tailwind v4 token classes, shape tokens (rounded-ui, shadow-ui, border-ui), shadcn/ui primitives in src/components/ui (sync-shadcn), CVA variants, data-slot, DynamicImage, lazy-loaded overlays, and Storybook stories with snapshot tests. Use when creating or editing a component in src/components, adding a shadcn primitive, fixing styling that ignores the theme, writing a *.stories.tsx file, or running pnpm storybook:test. Do not use for re-branding colors, fonts, or logos (use `storefront-next:sfnext-theming`), route loaders (use `storefront-next:sfnext-data-fetching`), or Page Designer registration (use `storefront-next:sfnext-page-designer`)./sfnext-configurationConfigure a Storefront Next app: config.server.ts (defineConfig, metadata/runtime/app), AppConfig types in src/types/config.ts, PUBLIC__ environment variable overrides, getConfig(context) / useConfig(), extension config (app.extension, app.serverExtension), protected paths, server-only secrets, and multi-site settings (commerce.sites, url.prefix, seoRoutes, siteAliasMap, cookie domain). Use when editing config.server.ts, adding a config value, an env var is ignored or "not applied", `pnpm config:inspect` / `config:push-env`, "Ignoring environment variable" warnings, protected config path errors, setting up a second site or locale URLs, or going through the pre-launch config checklist. Do not use for creating a project or the npm script list (use `storefront-next:sfnext-project-setup`), pushing bundles or MRT env management (use `storefront-next:sfnext-deployment` / `b2c-cli:b2c-mrt`), or hybrid proxy and cookie-sharing with SFRA (use `storefront-next:sfnext-hybrid-storefronts`)./sfnext-data-fetchingLoad and mutate data in a Storefront Next project: route loaders that call SCAPI through createApiClients from @/lib/api-clients.server, critical versus streamed (deferred) data, createBasketAction and BasketAction for cart actions, createActionError and ErrorCode, data() responses, useFetcher and the useScapiFetcher hook with its server allowlist, request-scoped dedupe and MRT timeouts, non-personalized SCAPI responses, shopper context, and custom API clients. Use for "fetch products in a loader", "stream data", "add a cart action", "call SCAPI from a component", "resource route", "NormalizedApiError", or "loader blocks the page". Do not use for route files or links (use `storefront-next:sfnext-routing`), when loaders re-run after actions (use `storefront-next:sfnext-revalidation`), Suspense/LCP tuning (use `storefront-next:sfnext-performance`), or defining SCAPI custom APIs (use `storefront-next:sfnext-scapi`).Other plugins' skills for the same job