Skip to Content

Quickstart

Add AI Try-On to a product page with a script tag, from npm or as a React component.

This page adds a Try on button to a pair of sunglasses. Other products differ only in their product type and data.

Get a key and allow your site

  1. In the AI Try-On dashboard, open Your website. Create a widget for the product's type, here Eyewear, if there is none yet: the dashboard keeps one widget per product type.
  2. Choose Install on the widget and copy the data-key value from the code: your publishable key, starting with pk_live_. Each widget has its own key. Install does not ask for your site's domain: set it on the dashboard's Store domain, or in Settings → Domains.
  3. Add localhost to your allowed domains while you develop. On other hosts AI Try-On's requests are refused and the try-on fails.

Add AI Try-On

Pick how your site is built. The portal remembers your choice on every page.

Load the script once, anywhere on the page. It opens AI Try-On for any element marked with data-vizbl-ai-try-on-dialog, including elements added to the page later.

<script defer src="https://cdn.vizbl.com/@vizbl/ai-try-on/dist/ai-try-on.embed.min.js"></script>

Mark the button and give it the product's data:

<button
  type="button"
  data-vizbl-ai-try-on-dialog
  data-vizbl-ai-try-on-api-key="pk_live_YOUR_PUBLISHABLE_KEY"
  data-vizbl-ai-try-on-product-type="eyewear"
  data-vizbl-ai-try-on-product-name="Aviator Sunglasses"
  data-vizbl-ai-try-on-product-image-src="https://your-store.example/images/aviator.jpg"
>
  Try on
</button>

The script brings its own copy of React, so it works on any site, whatever framework the page uses.

Replace pk_live_YOUR_PUBLISHABLE_KEY with your key and the image address with your product's.

Check that it works

Open the page on an allowed host and choose Try on. AI Try-On shows the product and asks for a photo, with tips on a good one for sunglasses the first time. Choose a photo and Generate my look: the result shows you wearing the product. If nothing opens, see Troubleshooting.

Next steps

  • Product types: the other nine types and the photo each needs.
  • Language: set the widget's language or let it follow the browser.
  • Options: every option in every way to install.

On this page