Skip to content

Tryon Platform Advanced API ​

The current iframe integration uses a scene page URL. Set the iframe's src to open a scene.

Scene page path ​

text
https://www.kivicube.com/tryon-scenes/<sceneId>
PartRequirementPurpose
<sceneId>Required; 32 letters or digitsSelects the Tryon scene to open

Copy the scene link from the Tryon Platform.

URL query parameters ​

ParameterRequiredDescription
langNozh for Chinese or en for English. Other or missing values use the browser language.
visitor-idNoA unique user identifier used to track users who are not logged in. It must be 32 characters; the Tryon component generates one if omitted.
sectionsNoA JSON array that matches works by name and overrides their links with webLink.
customSectionLinkClickNoSet to true to let the host page handle work-link clicks and receive section-link-click events.

Join multiple parameters with &:

text
https://www.kivicube.com/tryon-scenes/<sceneId>?lang=en&visitor-id=<32-character user ID>

sections ​

Each array item needs a name matching a work in the scene. The optional webLink must be a valid HTTP or HTTPS URL. Only matching items with a webLink override the original link.

js
const url = new URL("https://www.kivicube.com/tryon-scenes/<sceneId>");
url.searchParams.set(
  "sections",
  JSON.stringify([{ name: "Work name", webLink: "https://example.com/product" }]),
);
iframe.src = url.href;

Events ​

The scene page sends events to the host page with window.parent.postMessage. Each message contains type and detail:

typeWhen triggereddetail parameters
section-link-clickWhen the scene URL has customSectionLinkClick=true and the user clicks a work with a valid link.name: the work's name; webLink: its current link.

The host page can handle events by type. This example assumes the scene iframe has the ID tryonFrame:

js
const iframe = document.querySelector("#tryonFrame");

window.addEventListener("message", (event) => {
  if (event.source !== iframe?.contentWindow) return;
  if (event.origin !== new URL(iframe.src).origin) return;

  const message = event.data;
  if (typeof message?.type !== "string") return;

  console.log(message.type, message.detail);
});

Check both origin and source before using detail.