
Overview
The Komerza Embed SDK allows you to seamlessly integrate our checkout experience directly into your website. Instead of redirecting customers to a separate checkout page, the embed creates a modal overlay that keeps users on your site while providing a secure, optimized payment flow.Live Demo
See the Embed SDK in action with our interactive demo
Also integrate our analytics script to bring back visitor analytics on your
custom site for complete insights into your customer journey.
Features
Seamless Integration
Modal overlay keeps customers on your site during checkout
Lightweight
Minimal JavaScript bundle with no external dependencies
Theme Support
Light, dark, and auto themes to match your site design
CSP Compatible
Full Content Security Policy support with nonce integration
Quick Start
Add the following script to your website’s<head> or before the closing </body> tag:
Method 1: Data Attributes (Recommended for Simple Use Cases)
The easiest way to add checkout buttons to your site. Just add data attributes to any button or element:Data Attributes Reference
Letting the customer choose a variant
data-kmrza-variant-id is optional. If you omit it, checkout opens with a variant picker so the customer selects which variant they want before paying:
data-kmrza-variant-id when you want the customer to land on one specific variant with no choice to make.
Method 2: JavaScript API (For Advanced Use Cases)
For more control, use the JavaScript API to programmatically open the checkout:Multiple Items
You can add multiple products to the checkout at once:Complete Implementation Guide
HTML Setup
Here’s a complete HTML page example:JavaScript Integration
- Basic Integration
- Advanced Integration
- React Integration
API Reference
Komerza.init(options?)
Initializes the embed and automatically binds all elements with data-kmrza-* attributes.
nonce(optional): CSP nonce for injected styles and scripts
Komerza.open()), but should be called explicitly if you’re using data attributes.
Komerza.open(options)
Opens the checkout modal programmatically.
items(required): Array of products to add to checkoutproductId(required): Product identifiervariantId(optional): Product variant identifier. Omit it and checkout shows a variant picker so the customer choosesquantity(optional): Number of items (default: 1)
theme(optional): Color theme for the checkout modal'auto'- Matches user’s system preference (default)'light'- Light mode'dark'- Dark mode
affiliateCode(optional): Override affiliate tracking code, this will override any other affiliate tracking code whether that be from cookies or the URL.returnUrl(optional): Custom URL to redirect customers to after payment completion instead of the default store URL.email(optional): Prefill the customer’s email address in the checkout form.couponCode(optional): Prefill and automatically apply a coupon code at checkout.metadata(optional): Attach custom key-value metadata to orders for tracking purposes (e.g., campaign tracking, user IDs, referral sources).
Komerza.close()
Closes the checkout modal programmatically.
Basic Button
Dark Theme with Custom Quantity
Full Options Example (Data Attributes)
Full Options Example (JavaScript API)
Dynamic Cart with JavaScript
React Integration
Next.js Integration
TypeScript Support
Type definitions are included. You can use them like this:Troubleshooting
Embed not loading?
Full troubleshooting guide: console errors, CSP, ad blockers, framework
gotchas, and what to send support.
The checkout doesn’t open
- Make sure the script is loaded (
deferattribute is recommended) - Check browser console for errors
- Verify your product and variant IDs are correct
- If using data attributes, ensure
Komerza.init()is called after DOM is loaded
Modal appears behind other elements
The modal uses a high z-index (9999). If it’s still behind elements, check your CSS for competing z-index values.Theme doesn’t apply
Thetheme parameter accepts only 'light', 'dark', or 'auto'. Check for typos.
Affiliates
The Komerza Embed SDK supports affiliate tracking out of the box:- By default, the embed will automatically support deep linking using the
?refquery parameter on any URL where it runs. For example, a visitor arriving athttps://example.com/?ref=aff_12345will haveaff_12345attributed as the affiliate code. - The SDK will also read the
kmrza_affiliatecookie (if present) and pass that affiliate code to the order automatically, unless you override it. - You can override the automatic behavior by passing an explicit
affiliateCodetoKomerza.open().
Content Security Policy (CSP)
For enhanced security, configure your CSP headers to allow the Komerza embed:Best Practices
Performance
Performance
- Load the SDK script asynchronously when possible
- Initialize the SDK early but only open modals on user interaction
- Implement proper loading states for buy buttons
User Experience
User Experience
- Provide clear loading indicators - Handle network failures gracefully with fallback URLs - Support keyboard navigation (ESC to close)
Security
Security
- Always use CSP headers in production
- Validate product IDs and variant IDs before opening checkout
- Never expose sensitive data in client-side code
Analytics Integration
Analytics Integration
Also integrate our analytics script to bring back visitor analytics on your
custom site
Support
Need help with integration?Demo Page
Interactive demo with source code examples
Developer Support
Get technical support for integration issues
