# Top Page Integration

This page will guide you through integrating Virtusize on the Top Page of your website, which requires 3 steps:

1. Adding the placeholders

We currently support one type of widgets:

  • Fitting Room Discovery

This widget can be placed anywhere on your page, but it is recommended to specify the placement using placeholders. Adding placeholders will allow you to freely change the design of your page without worrying about breaking Virtusize widgets in the future.

2. Integrating the Virtusize script

This script is necessary for calling our central application responsible for displaying our widgets.

3. Verification

# Before you start

Please contact your sales representative to receive a Store Name.

# 1. Adding the placeholders

Please consult with your sales representative to determine the optimal positioning of the Virtusize tags.


If you are integrating Virtusize Fitting Room Discovery (FRD) widget, please add a placeholder tag where you want it to appear:

<div class="vs-placeholder-frd"></div>

It is possible to add multiple widgets of FRD by adding more placeholder tags.

# 2. Integrating the Virtusize script

The script can be easily integrated by setting variables for each environment in the script. Please place the following script just before closing the </body> tag and replace STORE_NAME, ENVIRONMENT, DEVICE_TYPE, USER_ID with the correct values.

const vsObject = {
  storeName: "STORE_NAME",
  env: "ENVIRONMENT",
  deviceType: "DEVICE_TYPE",
  userId: "USER_ID",
  page: "topPage"
};

(function() {
  window.vs = !window.hasOwnProperty("vs")
    ? vsObject
    : Object.assign(window.vs, vsObject);

  const { storeName, env, deviceType } = vsObject;
  const script = document.createElement("script");
  const firstScript = document.getElementsByTagName("script")[0];
  const protocol = document.location.protocol ? 'https' : 'http'

  Object.assign(script, {
    async: true,
    src: `${protocol}://integration.virtusize.com/${env}/${storeName}/${deviceType}.source.js`,
  });

  firstScript.parentNode.insertBefore(script, firstScript);
})();
value explanation
STORE_NAME This is the Store Name that you received from your sales representative.
ENVIRONMENT This can be either staging or production depending on what environment you are integrating on.
DEVICE_TYPE This can be either desktop or mobile depending on the device type the page is being accessed from. If your site is responsive (you serve the same resource to both desktop and mobile devices), please set this as desktop.
USER_ID - Set empty string ('') when the user is not logged in.
- Set the user's ID (using a hash function such as MD5, SHA-1, etc...) when the user is logged in.

# 3. Verification

After completing the integration, please share the Top Page URL with your sales representative.