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.
Hydrate HTML attributes
Use a data marker when the affiliate value needs to become an HTML attribute:<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:
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:
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: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: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:- Open a supported storefront path with an affiliate username.
- Confirm text, images, links, and conditional regions resolve.
- Open the equivalent path with
home. - Confirm fallback content remains usable and no affiliate-only region flashes.
- Test a second affiliate to catch values that were copied only once.
- Check keyboard focus, image alternative text, and screen-reader output after hydration.