SDK API Guide
Last updated:2025-03-18
Set User Identification
Interface Definition
- identifyAccount(user);
- Interface Description:
- Set the user identification, such as the user's membership card number.
- Parameter Description
- identity: The user identification ID.
- completion: The callback.
- Interface Description:
Call Example
let user = {completion: (code, message) => {}, identity: {"id": "value"}}
window.MAInterface.identifyAccount(user)
let user = {completion: (code, message) => {}, identity: {"id": "value"}}
window.MAInterface.identifyAccount(user)
This code block in the floating window
Get EUID
Interface Definition
- + EUID()
- Interface Description:
- Get the EUID of EngageLab MA.
- Interface Description:
Call Example
window.MAInterface.EUID((code, euid) => {
console.log(code, euid)
})
window.MAInterface.EUID((code, euid) => {
console.log(code, euid)
})
This code block in the floating window
Set User Contact Information
Interface Definition
- setUserContact(user)
- Interface Description:
- Support setting the values of multiple contact methods simultaneously. The key is the name of the contact method, and the value is the value of the contact method. Currently, 4 types of contact methods are supported: email, mobile_phone, landline_phone, and whatsapp_phone.
- Parameter Description
- contacts: The user's contact information.
- completion: The callback.
- Interface Description:
Call Example
let user = {
completion: (code, message) => { },
contacts: {}
}
user.contacts["Name of Contact Method"] = "Value of Contact Method" // For example: mobile_phone = 18800000000
window.MAInterface.setUserContact(user)
let user = {
completion: (code, message) => { },
contacts: {}
}
user.contacts["Name of Contact Method"] = "Value of Contact Method" // For example: mobile_phone = 18800000000
window.MAInterface.setUserContact(user)
This code block in the floating window
Set UTM Properties
Interface Definition
- setUtmProperties(attrs:any)
- Interface Description:
- UTM properties are standard event properties. If developers can identify which advertisement the user jumped from to access the App, it is recommended to set the UTM information, and we will pass this parameter when reporting events. Currently, the UTM properties that can be set are:
- utm_source: The source of the advertising campaign.
- utm_medium: The medium of the advertising campaign.
- utm_term: The term of the advertising campaign.
- utm_content: The content of the advertising campaign.
- utm_campaign: The name of the advertising campaign.
- utm_id: The ID of the advertising campaign.
- UTM properties are standard event properties. If developers can identify which advertisement the user jumped from to access the App, it is recommended to set the UTM information, and we will pass this parameter when reporting events. Currently, the UTM properties that can be set are:
- Interface Description:
Call Example
window.MAInterface.setUtmProperties({"utm_source": "value1"})
window.MAInterface.setUtmProperties({"utm_source": "value1"})
This code block in the floating window
Set User Properties
Set the values of user properties. If a user property does not exist, it will be automatically created in the background.
Overwrite and Update User Properties
- setProperty(user, completion)
- Interface Description:
- Overwrite and update the values of user properties.
- Only the latest reported data is saved, overwriting the historical data, such as the user's membership level.
- The content of these user properties is stored in an object. The key in it is the name of the user property and must be a string. The Value is the content of the user property and only supports types such as string, number, and Array.
- Currently, the elements in the value of the Array type only support being strings.
- If a certain user property already existed before, it will be overwritten this time; if it does not exist, it will be created.
- Call Example:
- Interface Description:
window.MAInterface.setProperty({key: "value"}, (code, message) => {})
window.MAInterface.setProperty({key: "value"}, (code, message) => {})
This code block in the floating window
Increment and Update User Properties
- increaseProperty(user, completion)
- Interface Description:
- Set an increment for the values of user properties.
- Add values to multiple numeric user properties. Accumulate all the reported data, such as the cumulative consumption amount.
- This interface can only be called for user properties of the number type, otherwise it will be ignored. If this user property did not exist before, the initial value is treated as 0.
- Call Example:
- Interface Description:
window.MAInterface.increaseProperty({key: 1}, (code, message) => {})
window.MAInterface.increaseProperty({key: 1}, (code, message) => {})
This code block in the floating window
Append User Properties
- addProperty(key, content completion)
- Interface Description:
- Append values to the values of user properties.
- Continuously add elements to this set. Duplicate elements are removed when stored in the database. If ABC already exists and CD is appended, the final result will be ABCD, such as the news liked by the user.
- Add some values to an Array - type property. The elements of this Array must be strings; otherwise, it will be ignored. At the same time, if the user property to be appended did not exist before, an empty Array will be initialized.
- Call Example:
- Interface Description:
window.MAInterface.addProperty("key", ["value1", "value2"], (code, message) => {})
window.MAInterface.addProperty("key", ["value1", "value2"], (code, message) => {})
This code block in the floating window
Remove User Properties
- removeProperty(key, content completion)
- Interface Description:
- Delete one or more values from an array - type property.
- Delete some values from an Array - type property. The elements of this Array must be strings; otherwise, it will be ignored. At the same time, if the user property to be removed did not exist before, there will be no effect.
- Call Example:
- Interface Description:
window.MAInterface.removeProperty("key", ["value1", "value2"], (code, message) => {})
window.MAInterface.removeProperty("key", ["value1", "value2"], (code, message) => {})
This code block in the floating window
Delete User Properties
Interface Definition
- deleteProperty(key, completion)
- Interface Description:
- Delete all the value content of a certain user property.
- If this user property did not exist before, it will be directly ignored.
- Interface Description:
Call Example
window.MAInterface.deleteProperty("key", (code, message) => {})
window.MAInterface.deleteProperty("key", (code, message) => {})
This code block in the floating window
Set Session Timeout
Interface Definition
- setSessionTimeout(time)
- Interface Description:
- Set the session timeout. When the page is placed in the background, the session timeout starts to be calculated. After exceeding the set time (30 minutes by default), this session will end.
- Interface Description:
Call Example
window.MAInterface.setSessionTimeout(60)
window.MAInterface.setSessionTimeout(60)
This code block in the floating window
Set Page Stay Time
Interface Definition
- setPageStayTime(time)
- Interface Description:
- Set the duration of the page stay time.
- Start timing after accessing the page. If the user stays on the page for time seconds without leaving, this event will be reported.
- By default, reports are made at 6 time points: 5 seconds, 30 seconds, 60 seconds, 2 minutes, 5 minutes, and 10 minutes. Developers can call this interface to add more time points.
- Interface Description:
Call Example
window.MAInterface.setPageStayTime(60)
window.MAInterface.setPageStayTime(60)
This code block in the floating window
Report Events
If an event does not exist, report it directly, and the background will automatically create the event.
Interface Definition
- onEvent(event)
- Interface Description:
- Report an event.
- Parameter Description
- event: The event to be reported. name is the event name, and properties is the event property information. The key in it is the property name, and the value is the property value.
- Interface Description:
Call Example
let event = {name: "name", properties: {key: "value"}}
window.MAInterface.onEvent(event)
let event = {name: "name", properties: {key: "value"}}
window.MAInterface.onEvent(event)
This code block in the floating window