Skip to main content
Initialize virtual.fit before loading the hosted script. The queue preserves commands until the loader is ready.

Complete example

Initialization fields

Start with siteKey, mount, and terms. Add advanced selectors only after the basic integration works.

Product object

Provide id or handle. The loader verifies it against the synced enabled catalog before mounting.
string
Stable product ID from catalog sync. Keep this ID unchanged when the shopper selects another variant.
string
Synced product handle. Provide id or handle.
string
Current shopper-facing title.
string
Product display fallback. It does not replace canonical prepared media.
string
Optional exact source_variant_id synced under the product.
string
Optional selected-variant display hint. Canonical synced variant media remains authoritative for try-on.
Call setProduct when a dynamic storefront changes the product or selected variant. See the Browser API.

Customer and authentication

auth.loginUrl accepts a string or callback. The callback receives:
  • returnTo — Current absolute page URL.
  • product — Resolved product context, or null.
  • location — Current href, origin, pathname, search, and hash.
showToAnonymous controls whether a logged-out shopper can see a login call to action when your virtual.fit settings require authentication. The customer-access policy in virtual.fit remains authoritative.

Terms object

Use one source for full terms:
  • fullHtml — Pass full HTML directly.
  • fullSelector — Read innerHTML from an existing host-page element.
If neither is set, virtual.fit uses its default terms. See Styling, labels, and terms.

Single-tag installation

When a platform allows one script tag but no inline queue, use data attributes:
JavaScript initialization is preferred when values are dynamic, variant selection changes after page load, or loginUrl needs callback logic.

Legacy aliases

Use terms for disclaimer and legal content. Use labels for interface text. Older content and ui aliases remain accepted for existing installs, but new integrations should not depend on them.