Overview
After receiving a session token from the handshake endpoint, you’ll embed Sticker into your application using an HTML iframe. This guide covers implementation, customization, and best practices.Basic iframe Implementation
The simplest integration uses a standard HTML iframe:iframe Attributes
Required Attributes
The Sticker embed URL with session_key parameter
Security sandbox flags. Must include:
allow-same-origin- Required for local storageallow-scripts- Required for app functionalityallow-forms- Required for checkoutallow-popups- Required for payment processing
Recommended Attributes
Set to
100% for responsive designMinimum
800px recommended. See responsive height section below.Feature policy. Include
payment for checkout:Set to
0 to remove borderAccessibility label for screen readers:
URL Parameters
Customize the embedded experience with URL parameters:The authentication token from the handshake endpoint
Color theme:
light (default) or darkInitial product category to display
Hide the top navigation bar (useful if embedding in a modal)
URL to redirect to after order completion
Responsive Design
Fixed Height
Simple approach with a fixed minimum height:Dynamic Height with postMessage
For a truly responsive experience, listen to height change messages from the iframe:Sticker sends height update messages whenever content changes. This ensures the iframe is always the perfect size without scrollbars.
Framework Integration Examples
postMessage API
Sticker communicates with your application using the postMessage API. Here are the events you can listen for:Events from Sticker (iframe → parent)
sticker:height
sticker:height
Sent whenever the iframe content height changes
sticker:ready
sticker:ready
Sent when the iframe has loaded and is ready
sticker:cart_updated
sticker:cart_updated
Sent when items are added/removed from cart
sticker:order_complete
sticker:order_complete
Sent when an order is successfully placed
sticker:navigation
sticker:navigation
sticker:error
sticker:error
Sent when an error occurs
Commands to Sticker (parent → iframe)
You can send commands to the iframe to control its behavior:Always specify the target origin when sending messages to prevent security issues.
Loading States
Show a loading indicator while the iframe initializes:Styling & Theming
Container Styling
Style the container div for better visual integration:Dark Mode
Support dark mode by passing the theme parameter:Security Considerations
iframe Sandbox
iframe Sandbox
Always include the sandbox attribute with minimal permissions:Never use
allow-top-navigation or allow-modals unless absolutely necessary.Verify Message Origin
Verify Message Origin
Always verify the origin of postMessage events:
Content Security Policy
Content Security Policy
Add Sticker to your CSP frame-src directive:
HTTPS Required
HTTPS Required
Always embed Sticker over HTTPS. Mixed content (HTTP page with HTTPS iframe) will be blocked by browsers.
Mobile Optimization
Ensure the iframe works well on mobile devices:Modal/Overlay Integration
Embed Sticker in a modal for a non-invasive integration:Troubleshooting
iframe Won't Load
iframe Won't Load
Possible causes:
- Invalid or expired session token
- CORS/CSP blocking the iframe
- Network connectivity issues
- Generate a fresh session token
- Check browser console for errors
- Verify CSP headers allow frame-src
iframe Shows Authentication Error
iframe Shows Authentication Error
Cause: Session token is invalid, expired, or already usedSolution: Generate a new session token via the handshake endpoint
Payment Not Working
Payment Not Working
Cause: Missing
allow="payment" attribute or insufficient sandbox permissionsSolution: Add allow="payment" and ensure sandbox includes allow-popupsHeight Not Adjusting
Height Not Adjusting
Cause: Not listening to postMessage height eventsSolution: Implement the postMessage listener for
sticker:height eventsBest Practices
Always Verify Origin
Check event.origin before processing postMessage events
Use Loading States
Show loading indicators for better UX
Handle Errors Gracefully
Display user-friendly error messages
Test on Mobile
Ensure the experience works well on all devices
Monitor Performance
Track iframe load times and errors
Refresh Tokens
Generate new tokens if the user returns after >5 minutes

