Skip to main content
Komerza Embed SDK in action

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:
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:
This is useful for a single buy button on a product with several editions, tiers or durations, where you would otherwise need one button per variant. Pass 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

API Reference

Komerza.init(options?)

Initializes the embed and automatically binds all elements with data-kmrza-* attributes.
Options:
  • nonce (optional): CSP nonce for injected styles and scripts
Note: This is called automatically when using the JS API (Komerza.open()), but should be called explicitly if you’re using data attributes.

Komerza.open(options)

Opens the checkout modal programmatically.
Parameters:
  • items (required): Array of products to add to checkout
    • productId (required): Product identifier
    • variantId (optional): Product variant identifier. Omit it and checkout shows a variant picker so the customer chooses
    • quantity (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

  1. Make sure the script is loaded (defer attribute is recommended)
  2. Check browser console for errors
  3. Verify your product and variant IDs are correct
  4. If using data attributes, ensure Komerza.init() is called after DOM is loaded
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

The theme 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 ?ref query parameter on any URL where it runs. For example, a visitor arriving at https://example.com/?ref=aff_12345 will have aff_12345 attributed as the affiliate code.
  • The SDK will also read the kmrza_affiliate cookie (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 affiliateCode to Komerza.open().
No manual setup is required for affiliate tracking - just use the standard initialization and checkout flow.

Content Security Policy (CSP)

For enhanced security, configure your CSP headers to allow the Komerza embed:
Then pass the nonce to the SDK:

Best Practices

  • 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
  • Provide clear loading indicators - Handle network failures gracefully with fallback URLs - Support keyboard navigation (ESC to close)
  • 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
Track the complete customer journey by combining the Embed SDK with our analytics script. This gives you insights into visitor behavior, conversion rates, and checkout abandonment 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
Last modified on July 31, 2026