Skip to main content
Affiliate hydration lets one cacheable storefront page work for both attributed and anonymous visitors. Your Liquid template emits a stable placeholder. The FairShare SDK replaces that placeholder in the browser after it resolves the visitor’s affiliate. Use the placeholder that matches where the value appears:

Render affiliate text

Fluid provides five affiliate elements: Put fallback text inside an element. Fluid keeps that text when the field is empty during the initial affiliate resolution.
These elements render in the light DOM, so your theme styles apply normally.

Hydrate HTML attributes

Use a data marker when the affiliate value needs to become an HTML attribute:
The supported markers are: <field> can be name, email, initials, avatar, my_site_url, or username. For my_site_url, you can set data-fluid-affiliate-base-url on the same element to use a different origin:
Use a data marker for eagerly loaded attributes such as image src. A browser can request a literal placeholder before hydration if you put one directly in src.

Put an affiliate username in a URL

Use {{ username }} when the affiliate username is one part of a link or form URL:
Fluid renders a stable sentinel into the cacheable page. The SDK replaces every sentinel with the resolved username. Anonymous visitors fall back to home. Use the sentinel in attributes that the browser follows after user interaction, such as href and action. For an eagerly fetched image source, use data-fluid-affiliate-src; the hydration API does not provide generic srcset or poster markers.

Show content conditionally

Liquid conditions run before the browser resolves the affiliate. Use hydration visibility markers for affiliate-dependent content:
Use affiliate to test whether any affiliate resolved. You can also test a specific field such as avatar or email. data-fluid-affiliate-show-if requires every comma-separated token to have a value. data-fluid-affiliate-hide-if hides the element when any listed token has a value. If both markers are present, the hide condition wins. Pre-hide show-if content with style="display: none" to prevent a flash before hydration. If an SPA changes affiliates without replacing the element, do not rely on hide-if alone to reveal content that it previously hid. Re-render that conditional region when the attribution changes.

React to hydrated content

Hydration happens after the initial HTML is parsed. If your script measures or copies hydrated content, observe the element instead of reading it immediately:
There is no public rescanForSentinels() method. Hydration reapplies when FairShare publishes an affiliate settings change and scans the current document again. In an SPA, render the destination content before that settings update. Prefer the custom elements for text that must continue reacting after the affiliate changes.

Test your theme

Test both attributed and anonymous paths:
  1. Open a supported storefront path with an affiliate username.
  2. Confirm text, images, links, and conditional regions resolve.
  3. Open the equivalent path with home.
  4. Confirm fallback content remains usable and no affiliate-only region flashes.
  5. Test a second affiliate to catch values that were copied only once.
  6. Check keyboard focus, image alternative text, and screen-reader output after hydration.
See supported storefront paths for route patterns and FairShare components for the SDK component inventory.