This article describes how to use the MoEngage Web SDK inside your browser extensions. You can integrate the MoEngage Web SDK within your browser extension to collect analytics and track user events and attributes.
info |
Note For now, we support only Google Chrome extensions. |
Analytics
MoEngage supports only the analytics channel in extensions for now. You can track events and attributes and user identities.
Permissions
No additional permissions are required in your manifest.json
when integrating the MoEngage SDK as a local file bundled with your extension.
Since the Google Chrome extension does not allow to fetch a script from an external URL, you must make a local copy of the script and place it in your project folder.
Getting Started
info |
Note Before you get started, ensure that you have read the Initial SDK setup guide of Web SDK to learn more about our JavaScript integration in general. |
To integrate MoEngage Web SDK, you will first need to download a copy of the latest JavaScript library. You can do this by downloading it directly from MoEngage CDN.
Find the CDN script based on your dashboard host. Right-click and download to save the file.
Dashboard Host | CDN URL |
---|---|
dashboard-01.moengage.com | https://cdn.moengage.com/release/dc_1/moe_webSdk.min.latest.js |
dashboard-02.moengage.com | https://cdn.moengage.com/release/dc_2/moe_webSdk.min.latest.js |
dashboard-03.moengage.com | https://cdn.moengage.com/release/dc_3/moe_webSdk.min.latest.js |
dashboard-04.moengage.com | https://cdn.moengage.com/release/dc_4/moe_webSdk.min.latest.js |
After the download is complete, ensure that you copy the moe_webSdk.min.latest.js
file somewhere into your extension’s directory.
Extension Pop-Up Windows
To add MoEngage SDK to an extension pop-up window, reference the local JavaScript file in your popup.html
, as you would in a regular website.
<html>
<!-- Add the Moengage library-->
<script src="/relative/path/to/moe_webSdk.min.latest.js"></script>
<title>popup.html</title>
</html>
Initialization
After you add MoEngage SDK to an extension pop-up window, you can initialise the library as usual.
Because cookies are not supported in browser extensions, you can disable cookies by initialising with disableCookies: true
.
window.Moengage = moe({
app_id: "XXXXXXXXXXXXXXXXX",
debug_logs: 0,
disableCookies: true
});
Refer the sample project for better understanding.