Script tag dynamic instances

Public Preview

Dynamic multi-instance for script tag / vanilla JS is currently in public preview.

This guide explains how to implement dynamic multi-instance tracking for Script tag / vanilla JS.

Requires @seeka-labs/converge version 1.10.4 or later via NPM. See module installation for setup.

SeekaIframeInstance

Use SeekaIframeInstance to create and destroy dynamic instances programmatically.

import { SeekaIframeInstance } from '@seeka-labs/converge/iframe';

const instance = new SeekaIframeInstance({
    org: 'org-id',
    id: 'instance-id',
    publicKey: 'public-key',
    onReady: () => {
        instance.sdk.track.viewContentItem({
            contentId: 'event-123',
        });
    },
    onError: (err) => {
        console.error('Failed to load:', err.message);
    },
});

instance.init();

// When navigating away - destroys iframe and all vendor scripts
instance.destroy();

Config

Required:

  • org (string) - Organisation ID
  • id (string) - Instance ID
  • publicKey (string) - Public key

Optional:

  • seekaPId (string) - Person ID to bridge from master. If omitted, reads from window.Converge.identity.personId.
  • sessionId (string) - Session ID to bridge from master. If omitted, reads from window.Converge.identity.touchAndGetSessionId().
  • consent (object) - Per-instance consent override (IAB purpose IDs). Omit to inherit from master.
  • seekaHost (string) - Override SDK host. Default: https://sdk.seeka.services
  • timeoutMs (number) - Load timeout in milliseconds. Default: 20000
  • onReady (function) - Called when the iframe SDK is ready.
  • onError (function) - Called if the iframe fails to load within the timeout.
  • onIdentityChanged (function) - Called when identity changes inside the iframe.

Properties

  • instance.sdk - SDK proxy with .track and .identity methods. undefined until ready.
  • instance.ready - true when initialized.
  • instance.destroyed - true after destroy() is called.

Usage

See multi-instance usage for general interaction patterns.