Browser SDK usage

Once the SDK is installed you can start working with the client.

Configuring

View the config reference for a full list of configuration options.

import {
  ConvergeSdk,
  TrackingActivityNames,
  ConvergeSdkLogEventLevel,
} from "@seeka-labs/converge";
import { BotDetectionConvergeSdkPlugin } from "@seeka-labs/converge-plugin-botdetection";
import { FacebookPixelConvergeSdkPlugin } from "@seeka-labs/converge-plugin-facebook-pixel";
import { SnapchatPixelConvergeSdkPlugin } from "@seeka-labs/converge-plugin-snapchat-pixel";
import { PinterestTagConvergeSdkPlugin } from "@seeka-labs/converge-plugin-pinterest-tag";
import { TikTokPixelConvergeSdkPlugin } from "@seeka-labs/converge-plugin-tiktok-pixel";
import { SeekaConvergeSdkPlugin } from "@seeka-labs/converge-plugin-seeka";

const converge = new ConvergeSdk({
  key: "(public key)",
  organisationId: "(Organisation ID)",
  debug: {
    isEnabled: true,
    minimumLevel: ConvergeSdkLogEventLevel.Verbose,
  },
  tracking: {
    analytics: {
      autoCollection: {
        activityNames: [
          TrackingActivityNames.ViewPage,
          TrackingActivityNames.ViewProduct,
        ],
      },
    },
    defaults: { currencyCode: "USD" },
  },
  plugins: [
    new BotDetectionConvergeSdkPlugin({}),
    new FacebookPixelConvergeSdkPlugin({ pixelId: "(Facebook pixel ID)" }),
    new SnapchatPixelConvergeSdkPlugin({ pixelId: "(Snapchat pixel ID)" }),
    new PinterestTagConvergeSdkPlugin({ tagId: "(Pinterest tag ID)" }),
    new TikTokPixelConvergeSdkPlugin({ pixelId: "(TikTok pixel ID)" }),
    new SeekaConvergeSdkPlugin(),
  ],
});

Interacting

View the method reference for a full list of methods.

Retrieving the person ID

The SeekaPId (Seeka profile ID / Seeka person ID) is available very early in the browser SDK lifecycle and can be retrieved in either of the following ways:

Via event listener

<script>
  window.addEventListener("converge.identity.changed", function (ev) {
    if(ev.detail.identifiers.seekaPId) { 
      console.log("Seeka person ID", ev.detail.identifiers.seekaPId); 
    } 
  });
</script>

Via identity SDK property

// After the SDK is ready, below can be called
console.log("Seeka person ID", Converge.identity.personId)

Cross domain tracking

If multiple websites are a part of your digital entity, cross domain tracking can be enabled to track users across domains.

This will enable cross domain, device and session tracking and additionally allow the platforms that are installed via Seeka to take advantage of the cross domain tracking.

Use this method to add cross domain tracking to a single link.

var oldUrl = 'https://my.subdomain.com';
var newUrl  = Converge.attribution.addCrossDomainTracking(oldUrl);
window.open(newUrl);

Configuring for domains

Use this method to add cross domain tracking to all links on a page that point to a set of specific domains.

The below snippet should be placed on all pages that cross domain tracking should be enabled for.

In the example below, replace the domains in the crossTrackingDomains array with the domains you wish to enable cross domain tracking on.

<script> 
  window.addEventListener("converge.sdk.ready", function () {
    var crossTrackingDomains = ["example.com", "example2.com"];
    var id = Converge.identity.getOrAssign();
    var personId = id.personId;

    crossTrackingDomains.forEach(function (domain) {
      document
        .querySelectorAll('[href*="' + domain.replace(/\./g, "\\.") + '"]')
        .forEach(function (link) {
          link.href = Converge.attribution.addCrossDomainTracking(link.href);
        });
    });
  });
</script>