Installations
npm install clevertap-web-sdk
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.24.1
NPM Version
6.14.12
Score
88.5
Supply Chain
100
Quality
98.4
Maintenance
100
Vulnerability
100
License
Releases
CleverTap Web SDK - v1.12.1
Published on 06 Feb 2025
CleverTap Web SDK - v1.12.0
Published on 28 Jan 2025
CleverTap Web SDK - v1.11.16
Published on 20 Jan 2025
CleverTap Web SDK - v1.11.15
Published on 14 Jan 2025
CleverTap Web SDK - v1.11.14
Published on 19 Dec 2024
CleverTap Web SDK - v1.11.13
Published on 18 Dec 2024
Contributors
Unable to fetch Contributors
Languages
JavaScript (98.51%)
TypeScript (1.06%)
HTML (0.29%)
CSS (0.12%)
Sass (0.01%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
1,076,782
Last Day
25
Last Week
25
Last Month
27,389
Last Year
413,168
GitHub Statistics
15 Stars
1,156 Commits
18 Forks
13 Watching
145 Branches
26 Contributors
Bundle Size
149.48 kB
Minified
42.21 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.12.1
Package Id
clevertap-web-sdk@1.12.1
Unpacked Size
1.10 MB
Size
275.73 kB
File Count
19
NPM Version
6.14.12
Node Version
10.24.1
Publised On
06 Feb 2025
Total Downloads
Cumulative downloads
Total Downloads
1,076,782
Last day
0%
25
Compared to previous day
Last week
-99.5%
25
Compared to previous week
Last month
-18.2%
27,389
Compared to previous month
Last year
13.1%
413,168
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
21
CleverTap Web SDK
👋 Introduction
The CleverTap Web SDK for Customer Engagement and Analytics
CleverTap brings together real-time user insights, an advanced segmentation engine, and easy-to-use marketing tools in one mobile marketing platform — giving your team the power to create amazing experiences that deepen customer relationships. Our intelligent mobile marketing platform provides the insights you need to keep users engaged and drive long-term retention and growth.
For more information check out our website and documentation.
To get started, sign up here
🎉 Installation
CleverTap Web SDK is available as an npm package or as a script to manually add to your website.
Use a package manager
npm install clevertap-web-sdk --save
or
yarn add clevertap-web-sdk
Manually add the script
1<script type="text/javascript"> 2 var clevertap = {event:[], profile:[], account:[], onUserLogin:[], notifications:[], privacy:[]}; 3 // replace with the CLEVERTAP_ACCOUNT_ID with the actual ACCOUNT ID value from your Dashboard -> Settings page 4clevertap.account.push({"id": "CLEVERTAP_ACCOUNT_ID"}); 5clevertap.privacy.push({optOut: false}); //set the flag to true, if the user of the device opts out of sharing their data 6clevertap.privacy.push({useIP: false}); //set the flag to true, if the user agrees to share their IP data 7 (function () { 8 var wzrk = document.createElement('script'); 9 wzrk.type = 'text/javascript'; 10 wzrk.async = true; 11 wzrk.src = 'https://d2r1yp2w7bby2u.cloudfront.net/js/clevertap.min.js'; 12 var s = document.getElementsByTagName('script')[0]; 13 s.parentNode.insertBefore(wzrk, s); 14 })(); 15</script>
🚀 Basic Initialization
Add your CleverTap account credentials
Only in case you are using a package manager
1import clevertap from 'clevertap-web-sdk' 2clevertap.privacy.push({optOut: false}) // Set the flag to true, if the user of the device opts out of sharing their data 3clevertap.privacy.push({useIP: false}) // Set the flag to true, if the user agrees to share their IP data 4clevertap.init('ACCOUNT_ID', 'REGION', 'TARGET_DOMAIN') // Replace with values applicable to you. Refer below
Here:
ACCOUNT_ID
(mandatory): This value can be got from Projects page on the CleverTap Dashboard.
REGION
(optional): This will be same as the region of the CleverTap Dashboard. Possible values: (in1/us1/sg1/aps3/mec1).
TARGET_DOMAIN
(optional): domain of the proxy server.
For SPAs you need to also set the following:
1clevertap.spa = true
Event Push
Events track what individual actions users perform in your app or website. Some examples of events include a user launching an app, viewing a product, listening to a song, sharing a photo, making a purchase, or favoriting an item.
1// event without properties 2clevertap.event.push("Product viewed"); 3 4// event with properties 5clevertap.event.push("Product viewed", { 6 "Product name": "Casio Chronograph Watch", 7 "Category": "Mens Accessories", 8 "Price": 59.99, 9 "Date": new Date() 10});
Profile Push
After you integrate our SDK, we will create a user profile for each person who launches your app or visits your website.
1// each of the below mentioned fields are optional 2// if set, these populate demographic information in the Dashboard 3clevertap.profile.push({ 4 "Site": { 5 "Name": "Jack Montana", // String 6 "Identity": 61026032, // String or number 7 "Email": "jack@gmail.com", // Email address of the user 8 "Phone": "+14155551234", // Phone (with the country code) 9 "Gender": "M", // Can be either M or F 10 "DOB": new Date(), // Date of Birth. Javascript Date object 11 "Photo": 'www.foobar.com/image.jpeg', // URL to the Image 12 13// optional fields. controls whether the user will be sent email, push etc. 14 "MSG-email": false, // Disable email notifications 15 "MSG-push": true, // Enable push notifications 16 "MSG-sms": true // Enable sms notifications 17 "MSG-whatsapp": true, // Enable whatsapp notifications 18 } 19})
Maintaining Multiple User Profiles on the Same Device using OnUserLogin
If multiple users on the same device use your app, you can use the clevertap.onUserLogin
method to assign them each a unique profile to track them separately.
Here is an example showing how to add a name and an email to a user’s profile:
1// with the exception of one of Identity, Email, or FBID 2// each of the following fields is optional 3 4clevertap.onUserLogin.push({ 5 "Site": { 6 "Name": "Jack Montana", // String 7 "Identity": 61026032, // String or number 8 "Email": "jack@gmail.com", // Email address of the user 9 "Phone": "+14155551234", // Phone (with the country code) 10 "Gender": "M", // Can be either M or F 11 "DOB": new Date(), // Date of Birth. Date object 12// optional fields. controls whether the user will be sent email, push etc. 13 "MSG-email": false, // Disable email notifications 14 "MSG-push": true, // Enable push notifications 15 "MSG-sms": true, // Enable sms notifications 16 "MSG-whatsapp": true, // Enable WhatsApp notifications 17 } 18})
Web Push
Web push notifications provide the ability to communicate brief, yet important alerts to your users while CleverTap’s rich segmentation and powerful infrastructure can help send time-sensitive, relevant, and personalized push messages at scale.
To know more on how to configure web push notifications for Chrome, Firefox and Safari, checkout CleverTap Web Push guide.
Offline Mode
The offline mode allows setting CleverTap SDK to offline. The setOffline
method determines the SDK online state. By default the offline state of the sdk is set to false
.
However, once the setOffline
method is passed with true
as described below, the CleverTap SDK goes offline. All the events are recorded and queued locally, but they are not sent to the CleverTap server.
When the setOffline
method is passed with false
, as described below, the CleverTap SDK goes online, and the queued events are sent to the server immediately.
1 clevertap.setOffline(true) // sets the sdk in offline mode.Events will be queued locally and will be fired only when offline mode is set to false 2 clevertap.setOffline(false) // disables the offline mode. Events will now get fired immediately 3
Debugging
This section is applicable for all browsers such as, Chrome, Firefox, and Safari. Error messages and warnings are logged to the JS console of the browser.
For verbose logging, enable verbose logging of all communication with the CleverTap servers by setting the WZRK_D
variable in sessionStorage. In the developer console of your browser type, sessionStorage['WZRK_D'] = '';
Alternatively, you can also set the log levels after calling clevertap.init()
in the following way:
1clevertap.setLogLevel(LOG_LEVEL) 2// Here Log Levels is an integer that can be any of the folowing: 3// 0: disable all logs 4// 1: display only errors 5// 2: display errors and info 6// 3: display all logs
𝌡 Example Usage
- A React Application showing the integration of our SDK in a create react app project.
- An Angular Application showing the integration of our SDK in an Angular CLI generated project.
🆕 Change Log
Refer to the CleverTap Web SDK Change Log.
📄 License
CleverTap Web SDK is released under the MIT license. See LICENSE for details.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:6
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Warn: no topLevel permission defined: .github/workflows/sw_build.yml:1
- Warn: no topLevel permission defined: .github/workflows/sw_release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_build.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_release.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sw_release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/sw_release.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/CleverTap/clevertap-web-sdk/sw_release.yml/master?enable=pin
- Info: 0 out of 13 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
116 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-c75v-2vq8-878f
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-3wcq-x3mq-6r9p
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-j4f2-536g-r55m
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-6h5x-7c5m-7cr7
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr
- Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg
- Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h
- Warn: Project is vulnerable to: GHSA-7x7c-qm48-pq9c
- Warn: Project is vulnerable to: GHSA-rc3x-jf5g-xvc5
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-6fx8-h7jm-663j
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-9m6j-fcg5-2442
- Warn: Project is vulnerable to: GHSA-hh27-ffr2-f2jc
- Warn: Project is vulnerable to: GHSA-rqff-837h-mm52
- Warn: Project is vulnerable to: GHSA-8v38-pw62-9cw2
- Warn: Project is vulnerable to: GHSA-hgjh-723h-mx2j
- Warn: Project is vulnerable to: GHSA-jf5r-8hm2-f872
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-72mh-269x-7mh5
- Warn: Project is vulnerable to: GHSA-h4j5-c7cj-74xg
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-9qmh-276g-x5pj
- Warn: Project is vulnerable to: GHSA-33f9-j839-rf8h
- Warn: Project is vulnerable to: GHSA-c36v-fmgq-m8hx
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-5q6m-3h65-w53x
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
5.2
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More