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.
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
init()
methodThe 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
page()
methodThe page()
method is used to record the page details whenever a user visits the page.
Usage:
Example:
The properties
parameter
The properties
parameter of the page()
call contains the below properties:
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
identify()
methodThe 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:
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
phone
String
Phone number
userid
String
Unique ID of the user
track()
method
track()
methodThis method is used to capture user behaviour and track all actions of the user. These actions are also known as events.
Usage:
Example:
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) orCommand+Option+I
(Mac) and go to theConsole
tabChrome:
Ctrl+Shift+J
(Windows) orCommand+Option+J
(Mac)Firefox:
Ctrl+Shift+K
(Windows) orCommand+Option+K
(Mac) and select theConsole
tabInternet Explorer: Press
F12
and go to theConsole
tab
In the console, type lmSMTObj
and press Enter
. If it shows an object as shown below, it means the SDK has loaded correctly.
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 installation guide to properly configure the SDK.
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.
Make sure the SDK is loaded only in the
<head>
tag of the webpage and the SDK API methods like thepage()
,identify()
,track()
are called after the SDK is loaded.Please check whether you are running any ad blockers that prevent SDK from loading.
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.
Make sure your system date and time is correct.
If nothing works, please contact us below.
Contact Us
To know more about the Lemnisk JavaScript SDK you can contact us.
Last updated