Skip to main content

Overview

The Komerza Analytics SDK allows you to track visitor behavior on your custom website and view the analytics directly in your Komerza Dashboard. With just a single script tag, you’ll get comprehensive visitor insights including page views, user sessions, conversion tracking, and more.

View Analytics

Access your visitor analytics in the Komerza Dashboard

Features

GDPR Compliant

Automatic cookie consent management with essential/optional cookies

Zero Configuration

Just include the script with your store ID - no complex setup required

Real-time Analytics

View visitor data instantly in your Komerza Dashboard

Privacy Focused

Respects user privacy with transparent cookie consent and Shadow DOM isolation

Quick Start

Single Script Integration

Add the analytics script to your HTML pages with your store ID:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Store</title>
  </head>
  <body>
    <!-- Your website content -->
    <h1>Welcome to My Store</h1>

    <!-- Komerza Analytics - Add before closing </body> tag -->
    <script
      data-store-id="your-store-id"
      src="https://cdn.komerza.com/ka.min.js"
    ></script>
  </body>
</html>
Replace your-store-id with your actual Komerza store ID from your dashboard. The analytics script automatically handles GDPR compliance by showing a cookie consent notice to visitors.
When a visitor first arrives on your site:
  1. Immediate Pageview: An IP-only pageview is recorded immediately (GDPR compliant)
  2. Cookie Notice Display: A GDPR-compliant notice appears in the bottom-right
  3. 20-Second Timer: If no response, “Required Only” tracking activates automatically
  4. User Choice: Visitor can choose “Required Only” or “Accept All” at any time
  5. Preference Storage: Choice is remembered for future visits (1-hour cookie expiry)
  • Required Only
  • Accept All
  • Random visitor ID (not fingerprinted)
  • Device type and browser name
  • Referrer information
  • Session tracking (1-hour expiry)
  • No cross-session tracking

Implementation Examples

Basic Website

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Online Store</title>
  </head>
  <body>
    <header>
      <h1>My Store</h1>
      <nav>
        <a href="/">Home</a>
        <a href="/products">Products</a>
        <a href="/about">About</a>
      </nav>
    </header>

    <main>
      <h2>Welcome to My Store</h2>
      <p>Discover amazing products...</p>
    </main>

    <footer>
      <p>&copy; 2025 My Store. All rights reserved.</p>
    </footer>

    <!-- Komerza Analytics -->
    <script
      data-store-id="7c1e4aa4-a28f-4855-a7e1-6dcc020d2083"
      src="https://cdn.komerza.com/ka.min.js"
    ></script>
  </body>
</html>

E-commerce Site

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Product Page - My Store</title>
  </head>
  <body>
    <div class="product-page">
      <h1>Amazing Product</h1>
      <div class="product-details">
        <img src="product-image.jpg" alt="Product" />
        <div class="product-info">
          <p class="price">$29.99</p>
          <button id="add-to-cart">Add to Cart</button>
          <button id="buy-now">Buy Now</button>
        </div>
      </div>
    </div>

    <!-- Komerza Analytics -->
    <script
      data-store-id="your-store-id"
      src="https://cdn.komerza.com/ka.min.js"
    ></script>

    <!-- Your product interaction scripts -->
    <script>
      document.getElementById("buy-now").addEventListener("click", function () {
        // Your checkout logic here
        // Analytics will automatically track this page interaction
      });
    </script>
  </body>
</html>

React/SPA Integration

For single-page applications, add the script once in your main HTML file:
<!-- public/index.html (React) or main HTML file -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My React Store</title>
  </head>
  <body>
    <div id="root"></div>

    <!-- Komerza Analytics -->
    <script
      data-store-id="your-store-id"
      src="https://cdn.komerza.com/ka.min.js"
    ></script>
  </body>
</html>
If you want to programmatically control consent (e.g., custom cookie banner):
<script
  data-store-id="your-store-id"
  src="https://cdn.komerza.com/ka.min.js"
></script>

<script>
  // Accept required-only tracking
  function acceptRequired() {
    window.KomerzaAnalytics.acceptRequired();
  }

  // Accept full analytics tracking
  function acceptAll() {
    window.KomerzaAnalytics.acceptOptional();
  }

  // Example: Custom button handlers
  document
    .getElementById("accept-required")
    .addEventListener("click", acceptRequired);
  document.getElementById("accept-all").addEventListener("click", acceptAll);
</script>

Privacy Features

  • Random visitor IDs: Required-only tracking uses crypto-random IDs (not fingerprinted)
  • Short expiry: All cookies expire after 1 hour
  • No cross-domain tracking: Cookies are site-specific
  • IP anonymization: Essential pageviews are IP-only, no visitor ID

Content Security Policy (CSP)

For sites with CSP headers, add the following to your CSP configuration:
Content-Security-Policy:
  script-src 'self' https://cdn.komerza.com;
  connect-src 'self' https://m-api.komerza.com;
The analytics script does not require CSP nonce integration as it loads from a trusted CDN. However, ensure https://cdn.komerza.com is in your script-src directive, and https://m-api.komerza.com is in your connect-src directive to allow data transmission.

Viewing Your Analytics

Once the script is installed and visitors start coming to your site:
  1. Login to Dashboard: Visit dashboard.komerza.com
  2. Navigate to Visitor Analytics: Click on the “Visitors” section
  3. View Insights: See real-time and historical visitor data
  4. Track Performance: Monitor conversion rates and user behavior

Ad Blocker Compatibility

The analytics script uses the filename ka.min.js which is less likely to be blocked by ad blockers compared to filenames containing “analytics” or “tracking”. However, some aggressive blockers may still block analytics requests.

Support