window.FairShareSDK. Everything else — cart widgets, lead capture, media — activates as soon as you add the relevant HTML elements or call the API.
Building a Fluid theme? Your storefront already loads the SDK from a Global Embed that Fluid manages, so don’t add the script tag to your theme. See Common theme pitfalls. Add the script yourself only on sites Fluid doesn’t host.
Basic Installation
Add the following snippet to every page where you want FairShare to run. Replaceyour-shop-id with your company’s Fluid subdomain — acme for acme.fluid.app. Keep type="module": the script is an ES module and fails to load without it.
id="fluid-cdn-script" on the tag — the SDK uses it to find its configuration.
Fluid-hosted storefronts already load the SDK through a global embed. Don’t add this tag to a Fluid theme — two copies can add items to the cart twice. Edit the embed instead. See FairShare SDK and the storefront.
Configuration Options
Customize SDK behavior by addingdata-* attributes to the script tag. Only data-fluid-shop is required; all other attributes are optional.
Attribution Override
By default, FairShare reads attribution signals from the current URL and stored cookies. You can override this by setting one or more attribution attributes directly on the script tag. Use this pattern when:- You’re building a rep-specific landing page and want to hard-code credit to a known rep.
- Your site runs outside the Fluid ecosystem and you’re passing rep identity from your own user session.
- You need to test attribution for a specific rep without using a share link.
share-guid → fluid-rep-id → email → username → external-id. It doesn’t check that the rep exists, so an attribute with an unknown value doesn’t fall through to the next one. The browser remembers an override: clear the site’s data after you remove one.
Using data-share-guid (the older name for data-username — Fluid matches the value against rep usernames):
Enable real-time cart updates
Setdata-realtime-enabled="true" to receive cart updates over Action Cable, Fluid’s WebSocket transport. Updates to the same cart from another tab, a droplet, or a support agent can reach your page without a refresh. It is also how a cart that Fluid fills in the background reaches the page. See Carts that fill in the background.
The loader tag that Fluid injects on every storefront always sets this attribute, so a Fluid theme needs no change. Set it yourself only when you install the SDK by hand outside a Fluid theme. Without it, the attribute defaults to off.
Use a custom WebSocket endpoint
The default endpoint iswss://websockets.fluid.app/cable. For a non-production environment, add data-cable-url with that environment’s WebSocket endpoint:
data-fluid-api-base-url does not change the WebSocket endpoint; configure data-cable-url separately when you use a different host.
Migrate from Pusher
Replacedata-pusher-enabled="true" with data-realtime-enabled="true" on your existing loader tag. The SDK still recognizes the Pusher option, but Fluid no longer publishes updates to Pusher, so that option alone does not deliver cart updates. If both options are enabled, Action Cable takes precedence.
Your loaded SDK bundle must include Action Cable support. On a tag you wrote, add
data-realtime-enabled="true"; updating the SDK bundle alone does not enable real-time sync. The tag that Fluid manages already includes it.Custom API Endpoint
Enterprise accounts may need to route SDK traffic to a dedicated API host. Setdata-fluid-api-base-url to your custom endpoint and all SDK requests will use it instead of the default Fluid API.
Debug Mode
Setdata-debug="true" to enable verbose logging in the browser console. Debug mode prints attribution resolution steps, API request details, and widget lifecycle events. Disable it before going to production.
Manual Initialization (SPA / React)
In single-page applications the<head> script tag may execute before your framework has mounted the component tree. If you need to initialize FairShare after a dynamic render, call initializeFluid() directly:
realtimeEnabled: true. Fluid storefronts need no setting, because their loader always enables it. Use cableUrl only when you need to override the default WebSocket endpoint:
initializeFluid() initializes the full SDK, including cart and widget
features. initializeFairshare() is a lower-level asynchronous initializer for
tracking and attribution only. Use initializeFluid() for storefront
integrations unless you intentionally need only the tracking layer.
Call initializeFluid() once per session — typically in your root component’s mount lifecycle hook (useEffect with an empty dependency array in React, onMounted in Vue, ngOnInit in Angular). The script tag must still be present in the document, but you can omit the data-fluid-shop attribute and provide it here instead.
To reset the SDK state — for example, when a user logs out — call:
reset() clears stored SDK data, the local cart, real-time connections, and
initialization state. If you only need to clear tracking and attribution data,
do not use resetFairshare() as a partial reset. FairShare and Fluid share
browser storage, so that method also removes stored cart, settings, and
authentication data.