Skip to main content

Web Integration

Embed the plugin in an iframe and load the JavaScript SDK on the same page.

There are two layouts:

  • Responsive modal (recommended): a button opens the plugin in a modal on desktop and full screen on tablet and mobile. The customer stays on your page, and the photo flow gets a focused screen.
  • Embedded: the plugin is part of the page. Use it for a dedicated skin analysis page.

Responsive modal​

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.modal-overlay {
position: fixed; inset: 0; z-index: 1000;
display: none; align-items: center; justify-content: center;
background: rgba(0, 0, 0, 0.5);
}
.modal-overlay.open { display: flex; }
.modal-content {
position: relative; width: 1160px; height: 700px;
background: #fff; border-radius: 12px; overflow: hidden;
}
.close-button { position: absolute; top: 8px; right: 12px; z-index: 10; }
#skinai-iframe { width: 100%; height: 100%; border: none; display: block; }
/* Tablet and mobile: full screen */
@media (max-width: 1200px) {
.modal-content { width: 100%; height: 100dvh; border-radius: 0; }
}
</style>
</head>
<body>
<button id="open-skinai">Analyze my skin</button>

<div class="modal-overlay" id="skinai-modal">
<div class="modal-content">
<button class="close-button" id="close-skinai" aria-label="Close">✕</button>
<iframe id="skinai-iframe" allow="camera *;" title="Skin Analysis"></iframe>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js"></script>
<script>
const modal = document.getElementById('skinai-modal');
const iframe = document.getElementById('skinai-iframe');

document.getElementById('open-skinai').addEventListener('click', () => {
if (!iframe.src) iframe.src = 'https://plugin.pulpoar.com/skinai/<project-key>';
modal.classList.add('open');
document.body.style.overflow = 'hidden'; // lock page scroll
});

document.getElementById('close-skinai').addEventListener('click', () => {
modal.classList.remove('open');
document.body.style.overflow = '';
});

pulpoar.onSkinScoreCalculate((payload) => console.log('Skin score:', payload));
pulpoar.onAddToCart((payload) => console.log('Add to cart:', payload));
</script>
</body>
</html>

Embedded​

<iframe
id="skinai-iframe"
src="https://plugin.pulpoar.com/skinai/<project-key>"
allow="camera *;"
title="Skin Analysis"
style="border: none; width: 1200px; height: 720px;"
></iframe>

<style>
@media (max-width: 768px) {
#skinai-iframe { width: 100% !important; height: 768px !important; }
}
</style>

<script src="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js"></script>
<script>
pulpoar.onReady((payload) => console.log('Ready:', payload));
pulpoar.onProductVisit((payload) => console.log('Product visit:', payload));
</script>

The allow="camera *;" attribute is required for the camera to work inside the iframe.

Iframe dimensions​

The iframe size decides which layout the plugin shows. Use these sizes:

LayoutDeviceWidthHeight
ModalDesktop1160px700px
ModalTablet and mobile100%100dvh (full screen)
EmbeddedDesktop1200px720px
EmbeddedMobile100%768px

The plugin switches layout at these widths:

LayoutIframe width
Desktop1135px and above
Tablet701px to 1134px
Mobile700px and below
warning

Avoid widths close to a breakpoint. The plugin may switch layout unexpectedly, and parts of the UI can overlap or be cut off. To check your sizes during development, add ?mode=integration to the iframe URL. See Integration mode.

Go to Product​

In a browser, the Go to Product button opens the product's URL from Studio. To handle it yourself, for example to open the page in your single-page app, listen to onProductVisit.

Camera​

  • Serve your page over HTTPS.
  • The browser asks for camera permission when the customer first takes a photo.
  • If the customer denies it, the plugin fires onCameraPermissionDeny. Use it to explain how to turn the camera on, or suggest uploading a photo instead.