LogoLogo
WebsiteBlog
  • Introduction
  • CDP Overview
  • Identity Resolution
  • CDP Guidelines for Data Sanity and Campaign Governance
  • Login and User Management
    • Login to the platform
    • Change Password / Retrieve your Account
    • Role Based Access Control
      • User Management
      • Roles
    • Single Sign-On (SSO)
  • Events
    • Events Overview
    • App Events
    • Track
    • Identify
    • Page
    • Screen
    • Event Dictionary
  • Sources
    • Sources Overview
    • Android SDK
    • iOS SDK
    • JavaScript SDK
    • React Native SDK
    • Flutter SDK
    • REST API
    • Adobe Analytics Exports
    • SFTP
    • Kafka
    • Offline File Ingestion
  • Destinations
    • Destinations Overview
    • Quora Pixel
    • Hotjar
    • Clevertap
    • Google Analytics 4 (GA4)
    • Meta Pixel
    • Meta Conversion API
    • LinkedIn Insight Tag
    • Adobe Target
    • AppsFlyer
    • AWS S3
    • Criteo
    • Kafka
  • Integrations
    • Rudderstack
    • Azure Blob
    • Adobe Launch Private Extension
    • Adobe Launch Extension
    • Salesforce CRM
    • Microsoft Dynamics 365
  • Customer One View
    • Introduction
    • Basic details, Attributes and Devices
    • Segment and Engagement
    • Activity
  • Segments
    • Getting Started
    • Create a Segment
  • Channels
    • Getting Started
    • A/B Testing
    • SMS
      • Set up an SSP
        • Netcore
        • Twilio
        • Adobe Campaign Classic
        • Gupshup
        • Unifonic
        • Infobip
        • Tubelight
      • Add an SSP
      • Create SMS campaign
      • FAQs
    • Email
      • Set up an ESP
        • SendGrid
        • SendInBlue
        • SparkPost
        • Taximail
        • Netcore
        • Adobe Campaign Classic
        • Mailchimp
        • Oracle Email Delivery
        • Infobip
        • Vision6
      • 🆕Add an ESP
      • Create Email campaign
      • Common use cases with Email Editor
      • Why Email Notification may not get delivered?
      • FAQs
    • App Push Notification
      • Create App Push Notification - Android
      • Create App Push Notification - iOS
      • Why App Push Notification may not get delivered?
      • FAQs
    • WhatsApp
      • Configure a WSP
        • Yellow Messenger
        • Infobip
        • Gupshup
        • BIK.ai
        • Vonage
        • Sinch
        • Tubelight
      • Create WhatsApp campaign
      • FAQs
    • RCS
      • Add an RCS API
      • Example: Netcore RCS API
      • Create an RCS campaign
      • FAQs
    • Web Push Notification
      • Create a Web Push Notification
      • Create a Default Web Push Notification
      • FAQs
    • On-site Notification
      • Create On-site Notifications.
      • Common use cases with On-site Notification.
      • Notification Templates
    • Banner Personalization
      • Create a Personalized Banner
      • Create a Default Banner
    • External API
      • Create Engagement
      • Test your API configuration
      • Example Use Cases of External APIs
        • Use case 1: HubSpot - Create Contacts API
        • Use case 2: Exotel's Make a call API
        • Use case 3: Mailmodo's Send Campaign Email API
  • Ramanujan AI
    • Lead scoring
    • Channel Orchestration
    • Content Generator
      • Generate Web Push Content
  • Journey Builder
    • Overview- Journey Builder
    • View all Journeys
    • Create a Journey
    • Journey Reports
    • FAQs
  • Audience Export
    • Facebook Export Channel
    • Google Ads Export Channel
  • Analytics
    • Dashboard
      • Guiding through the Dashboard
      • Unique Profile
      • Profile and Merge Trends
      • Campaign and Revenue Dashboard
    • Campaign Summary
    • Events Occurrence
    • Event Telemetry
    • App Installs and Uninstalls
    • Funnels
    • Paths
    • Traffic Analysis
    • Cohorts
    • Data sanity between Funnels, Paths and Events
    • FAQs
  • Developer APIs
    • User Profile API
    • WhatsApp Opt-in/Opt-out API
    • Subscription Management
  • Settings
    • Product Label
    • Frequency Caps
    • Contacts
Powered by GitBook
On this page
  • What is the Lemnisk JavaScript SDK?
  • Installing the Lemnisk JavaScript SDK
  • JavaScript SDK APIs
  • init() method
  • page() method
  • identify() method
  • track() method
  • Supported Browser Versions
  • FAQs
  • Common Troubleshooting steps
  • Contact Us
  1. Sources

JavaScript SDK

Detailed technical documentation on the Lemnisk JavaScript SDK to send data from your website to your destinations via Lemnisk.

This document acts as a reference for the JavaScript SDK API documentation. Please ensure that you have an agreed-upon Event Tracking Plan from your Lemnisk Customer Success Point of Contact in conjunction with this document for the correct and complete implementation.

What is the Lemnisk JavaScript SDK?

Lemnisk JavaScript SDK can be used to track and send user events from your website to various destinations of your choice. These destinations can be configured in the CDP Dashboard.

Installing the Lemnisk JavaScript SDK

Add the below code to your website’s <head> section to integrate the Lemnisk JavaScript SDK.

<script type= "text/javascript"> 
window.lmSMTObj = window.lmSMTObj || [];
var methods = [
    "init",
    "page",
    "track",
    "identify"
]
for (var i=0; i<methods.length; i++) {
    lmSMTObj[methods[i]] = function(methodName){
        return function(){
            lmSMTObj.push([methodName].concat(Array.prototype.slice.call(arguments)));
        };
    }(methods[i]);

}
lmSMTObj.init("<WRITE_KEY>")

var a = document.createElement("script");
a.type = "text/javascript";
a.async = !0;
a.src = "//cdn25.lemnisk.co/ssp/st/<CAMPAIGN_ID>.js";
var b = document.getElementsByTagName("script")[0];
b.parentNode.insertBefore(a, b);
</script>

You can find your source write key in the CDP Dashboard, and the campaign ID will be provided by our delivery team.

Please make sure that you only enter the above code snippet in the website's <head> section and nowhere else. Using Lemnisk SDK with tag managers (such as GTM) is strictly not recommended. There are several reasons for that:

  • Using Lemnisk with tag managers makes it difficult to determine the root cause of technical problems, and complicates troubleshooting.

  • It may lead to loss of data while capturing the information.

  • It will lead to further delays and cause performance issues.

JavaScript SDK APIs

Method

Description

init()

Loads the SDK with the write key.

page()

Records page views whenever a user visits a page

identify()

Associates users and their traits or actions

track()

Keeps track of user actions and important events

lmSMTObj is the global JavaScript object that is attached to the window object. You can access it in your code after initialising the JavaScript SDK. All SDK API methods are part of this object.

init() method

The init() method loads the Lemnisk JavaScript SDK with your write key.

Usage:

lmSMTObj.init("WRITE_KEY");

You need to replace WRITE_KEY with the write key in the Lemnisk CDP Dashboard.

Parameter

Type

Description

WRITE_KEY

String

Write key of the source

page() method

The page() method is used to record the page details whenever a user visits the page.

Usage:

lmSMTObj.page("pageName", {properties},{otherIds}, function())

Example:

lmSMTObj.page(”home”, {
	"path": "/academy/",
	"title": "Analytics Academy",
	"url": "https://lemnisk.co"
}, {
		"trackerId": "6791c47a-0178-47bc-8711-86a2c67b2255",
}, function() {})

The properties parameter

The properties parameter of the page() call contains the below properties:

{
  path: String,
  referrer: String,
  search: String,
  title: String,
  url: String,
  keywords: Array
}

Parameter

Type

Description

path

String

referrer

String

search

String

title

String

url

String

Full URL of the page

keywords

String

A list/array of keywords describing the content of the page. This is not automatically collected

path , referrer , search , title and url are automatically collected using DOM API so you don't need to send them separately.

identify() method

The identify call lets you tie a user to their actions and record traits about them. It includes a unique User ID and any optional traits you know about the user, like their email, mobile, any other id etc.

Usage:

lmSMTObj.identify("userId", {properties}, {otherIds}, function() {})

Example:

lmSMTObj.identify(”6791c47a-0178-47bc-8711-86a2c67b2255”, {
	"firstName": "John",
	"lastName": "Doe",
	"gender": "Male",
	"age": "27",
	"city": "Mumbai"
}, {
		"email": "john.doe@gmail.com",
		"phone": "9848012345"
}, function() {})

The properties parameter

The properties parameter of the identify() call contains the below properties:

Parameter

Type

Description

name

String

Full name

firstname

String

First name

lastname

String

Last name

age

String

Age

address

String

Address

dob

String

DoB in the format yyyy-mm-dd

email

String

Email

phone

String

Phone number

userid

String

Unique ID of the user

track() method

This method is used to capture user behaviour and track all actions of the user. These actions are also known as events.

Usage:

lmSMTObj.track("event_name", {properties}, {otherIds}, function() {})

Example:

lmSMTObj.track("addToCart", {
  "products": [
    {
      "name": "product_name",
      "id": "product_id",
      "category": "category_name",
      "subprod": {
        "name": "sub_product",
        "price": "40"
      }
    }
  ]
},
{
    "trackerId": "6791c47a-0178-47bc-8711-86a2c67b2255"
}, function() {});

Parameter

Type

Description

event_name

String

Name of the event

Supported Browser Versions

If your browser supports ES5 and further versions, the SDK will be fully supported.

FAQs

This section will find answers to most of your questions and solutions to some of the most common problems you may encounter while using the Lemnisk JavaScript SDK.

Q1. Where do I find the write key for my source?

Go to CONNECT > Connections > Sources from the sidebar. Click on any source name. Click on the How to add Lemnisk to your Website? heading. You will find the Write Key present there.

Q2. How to verify if the Lemnisk JS SDK is installed correctly?

To check if the SDK has loaded correctly, open the JavaScript console in your browser:

  • Safari: Ctrl+Alt+I (Windows) or Command+Option+I (Mac) and go to the Console tab

  • Chrome: Ctrl+Shift+J (Windows) or Command+Option+J (Mac)

  • Firefox: Ctrl+Shift+K (Windows) or Command+Option+K (Mac) and select the Console tab

  • Internet Explorer: Press F12 and go to the Console tab

In the console, type lmSMTObj and press Enter. If it shows an object as shown below, it means the SDK has loaded correctly.

Q3. Can I load the SDK more than once?

Though it is technically possible to load the SDK more than once, we DO NOT recommend doing so.

Q4. Is there any size limit on the payload of the request?

No. There is no limit on the payload of the request.

Common Troubleshooting steps

In case you encounter any issues with the SDK, follow the steps below to fix the errors and run the SDK correctly.

  1. Make sure the SDK is loaded only in the <head> tag of the webpage and the SDK API methods like the page(), identify(), track() are called after the SDK is loaded.

  2. Please check whether you are running any ad blockers that prevent SDK from loading.

  3. Try clearing all cookies and cache and retry. If the problem persists, check your browser extensions or 3rd party apps that may be interacting with the network.

  4. Make sure your system date and time is correct.

  5. If nothing works, please contact us below.

Contact Us

PreviousiOS SDKNextReact Native SDK

Last updated 1 month ago

Path portion of the URL of the page. Equivalent to from DOM API

Full URL of the previous page. Equivalent to from the DOM API.

Query string portion of the URL of the page. Equivalent to from the DOM API

Title of the page. Equivalent to from the DOM API

If the above command gives you an error Uncaught ReferenceError: lmSMTObj is not defined, it means that the SDK was not properly installed or instantiated. Refer to the to properly configure the SDK.

To know more about the Lemnisk JavaScript SDK you can .

installation guide
contact us
location.pathname
document.referrer
location.search
document.title
Source ID