Web SDK Integration Guide

This document is a standard integration guide for the MA Web SDK.

Preparations before Integration

  • To use the EngageLab MA service, you need to integrate the WebPush module first.
  • Prepare an accessible HTTPS web service domain name. After integration, the pages need to be tested and debugged under this domain name. Web offline push does not support local debugging or HTTP.
  • Access Engagelab WebPush, and on the [Integration Settings] - [Website Domain Name] page, fill in the HTTPS web service domain name.

Screenshot 2022-11-29 11.08.16.png

Product Description

The MA module in the EngageLab Web SDK provides data collection and reporting functions, which are used in scenarios such as EUID generation, user property setting, and event reporting.

Main Scenarios:

Set various types of properties and report various types of events.

Obtain Application Information

You need to create an application on the WebPush console. After successful creation, an AppKey will be automatically generated to identify this application. For details, refer to the Application Settings Document.

SDK Access

Go to the Console, download the SDK, and include the JavaScript on each page:

<script type="text/javascript" src="./webPushSdk.min.3.0.0.js"></script>
              
              <script type="text/javascript" src="./webPushSdk.min.3.0.0.js"></script>

            
Este bloque de código se muestra en una ventana flotante

Tips

After importing this JavaScript, pass the maOpen property with a value of true to enable the MA configuration, allowing you to use the relevant APIs and functions of MA.

SDK Initialization

// Initialization (Enable MA) MTpushInterface.init({ appkey: "", // Required, see above for application information user_str: "adminDemo", // Required, user identifier to mark the user swUrl: "url", // Default: "/sw.min." + sdkEnv.version + ".js". This configuration is the server worker file address. The domain must be the current domain, and the path determines the server worker scope. debugMode: true,// Set whether to enable debug mode. true will print more log information; false will only output logs of level w and e. channel: "default-channel",// Channel name, default value: default-channel appName: "string",// Used to set the website name for reporting maOpen: true, // Toggle to enable MA function userIdentity: { userId: "1234567890", anonymousId: "anonymous123" },// Set user identity during MA initialization. Supported since v3.3.4, applicable for enterprises providing MA services exclusively to logged-in members maCompletion: (code, msg) => {// MA initialization callback if (code === 0) { console.log("✅MA SDK initialized successfully!"); } else { console.error("❌MA SDK initialization failed:", msg); } } });
              
              // Initialization (Enable MA)
MTpushInterface.init({
  appkey: "", // Required, see above for application information
  user_str: "adminDemo", // Required, user identifier to mark the user
  swUrl: "url", // Default: "/sw.min." + sdkEnv.version + ".js". This configuration is the server worker file address. The domain must be the current domain, and the path determines the server worker scope.
  debugMode: true,// Set whether to enable debug mode. true will print more log information; false will only output logs of level w and e.
  channel: "default-channel",// Channel name, default value: default-channel
  appName: "string",// Used to set the website name for reporting
  maOpen: true, // Toggle to enable MA function
  userIdentity: { userId: "1234567890", anonymousId: "anonymous123" },// Set user identity during MA initialization. Supported since v3.3.4, applicable for enterprises providing MA services exclusively to logged-in members
  maCompletion: (code, msg) => {// MA initialization callback
        if (code === 0) {
          console.log("✅MA SDK initialized successfully!");
        } else {
          console.error("❌MA SDK initialization failed:", msg);
        }
  }
});

            
Este bloque de código se muestra en una ventana flotante

More APIs

For the usage of other APIs, refer to the interface documentation: Web SDK API.

icon
Contacto