Skip to main content
MindTouch Success Center

Analytics Connector Events

Applies to:
MindTouch (current)
Role required:
Admin

Events

mindtouch-web-widget:environment-info:ready

Fired when the Analytics Connector is created. The event data contains the following properties:

Name Type
embedId string
document.addEventListener('mindtouch-web-widget:environment-info:ready', ({ data }) => {
    const embedId = data.embedId;
});

mindtouch-web-widget:environment-info:loaded

Fired when the Analytics Connector is loaded. The event data contains the following properties:

Name Type
embedId string
widget.userActivityToken string
widget.initFormActivityLogger function
document.addEventListener('mindtouch-web-widget:environment-info:loaded', ({ data }) => {
    const embedId = data.embedId;
    
    // programmable connector interface contains properties and functions
    const widget = data.widget;
    const token = widget.userActivityToken;
    widget.initFormActivityLogger('case');
});

mindtouch-web-widget:environment-info:user-activity-token-changed

Fired when the current MindTouch session's user activity token changes. This could be in response to the user signing in or out of the MindTouch site. The event data contains the following properties:

Name Type
userActivityToken string
document.addEventListener('mindtouch-web-widget:environment-info:user-activity-token-changed', ({ data }) => {
    const token = data.userActivityToken;
});

mindtouch-web-widget:environment-info:form-activity-logger-ready

Fired when the form activity logger has been initialized. The event data contains the following properties:

Name Type
logger FormActivityLogger
document.addEventListener('mindtouch-web-widget:environment-info:form-activity-logger-ready', ({ data }) => {
    const logger = data.logger;
});

mindtouch-web-widget:environment-info:form-activity-logger-submitted

Fired when the form activity logger has logged a form submission. The event data does not contain any properties.

document.addEventListener('mindtouch-web-widget:environment-info:form-activity-logger-submitted', () => {  });

Properties

embedId

embedId : string

The id of the connector that uniquely identifies it.

initFormActivityLogger

initFormActivityLogger(string type, { string? id }) : Promise<FormActivityLogger>

Initialize a form activity logger, in order to collect ticket submission behavior for the Self-Service Activity Report. This function accepts the following parameters:

Name Type Description
type string The form type to track (allowed: case)
id (optional) string? Previously generated form activity logging id to identify the form between form submission page reloads
// form activity logger initialization can return a promise to be used in an async function
document.addEventListener('mindtouch-web-widget:environment-info:loaded', async ({ data }) => {
    const widget = data.widget;
    const logger = await widget.initFormActivityLogger('case');
    logger = await widget.initFormActivityLogger('case', { id: '123' });
});

// form activity logger initialization will also fire a mindtouch-web-widget:environment-info:form-activity-logger-ready DOM event, for programming in an environment without async support
document.addEventListener('mindtouch-web-widget:environment-info:form-activity-logger-ready', ({ data }) => {
    const logger = data.logger;
});
document.addEventListener('mindtouch-web-widget:environment-info:loaded', ({ data }) => {
    const widget = data.widget;
    widget.initFormActivityLogger('case');
    widget.initFormActivityLogger('case', { id: '456' });   
});

userActivityToken

userActivityToken : string

Retrieve the current MindTouch session's user activity token.

Types

FormActivityLogger

A utility that can log user behavior on web forms. This type has the following symbols:

Name Type Description
id string The form activity logging id
type string The form type
submit function : Promise<bool> Sends a form submission tracking event to the MindTouch API
const id = logger.id;
const type = logger.type;

// submit can return a promise
(async () => {
    const result = await logger.submit();
    if(result) {
    
        // success!
    }
});

// submit can fire an event
document.addEventListener('mindtouch-web-widget:environment-info:form-activity-logger-submitted', () => {

    // success!    
});
logger.submit();
  • Was this article helpful?