Event Listener Reference

OpenWeb's event listeners listen for events to occur on the client side and then execute the appropriate code in response. This reference explains the event listener syntax and details the available arguments.



Syntax

All event listeners use the following syntax.

document.addEventListener(event, function)
ArgumentDescription
event stringThis is the name of the event.
function functionThis is the function to execute when the event occurs.

As an example, you could add spot-im-current-user-sent-message-clicked to a <script> tag to trigger an event when a user sends a comment they have written. Then, the event.detail will be logged to the console after the event is fired.

document.addEventListener('spot-im-current-user-sent-message-clicked', function(event) {
    // event.detail includes information relevant to this event
    console.log(event.detail);
});

Multiple events can be used within a single <script> tag.



🚧

We strongly recommend that the <script> element is placed within the header. Any events that occur before the listener registration will be lost. Therefore, make sure events are registered as early as possible and before OpenWeb loads.



General

FunctionDescription
spot-im-launcher-loadedThe Launcher script has loaded on the page.
OPEN_WEB.initOW()When called, OpenWeb modules load immediately.

document.addEventListener("click", function() {
    __OPEN_WEB__.initOW()
}); 

By default, OpenWeb waits for an initial scroll by the user before attempting to load any products.


Conversation and Live Blog

📘

When an event is shown with an event.meta object in the following tables, this applies only to Conversation.

"event": {
  "detail": {
    "userId": "VIEWED_PROFILE_USER_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT" or null
  }
}

The event.meta object is not returned for Live Blog events.


Comment Context Menu

EventDescription
spot-im-clicked-delete-messageThe user has clicked to delete a comment posted.

event.detail
{
  "message_type": "comment or reply",
  "message_id": "MESSAGE_ID",
  "parent_id": "PARENT_ID"
}
spot-im-clicked-edit-messageThe user has clicked to edit the contents a comment posted.

event
"event": {
  "detail": {
    "message_type": "comment or reply",
    "message_id": "MESSAGE_ID",
    "parent_id": "PARENT_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-clicked-message-context-menuThe user has clicked to open the comment's context menu.

event.detail
{
  "message_type": "comment or reply",
  "message_id": "MESSAGE_ID",
  "parent_id": "PARENT_ID"
}
spot-im-clicked-mute-userThe user has clicked to mute another user.
spot-im-share-typeThe user has chosen to share the comment on a specific option. Event details include which share option was chosen.

event.detail
{
  "type": "facebook or link or twitter",
  "message_type": "comment or reply",
  "message_id": "MESSAGE_ID",
  "parent_id": "PARENT_ID",

}

Comments

EventDescription
floating_unit_clickedThe user has clicked the floating unit. Event details include the state (type) of the floating unit that was clicked and the platform (source).

event.detail
{
   "type": "static or typing",
   "source": "mobile-web or desktop"
}
ow-embedded-link-eventThe user has clicked a hyperlink or on an embed inside a comment. Event details include which type of element was clicked.

event.detail
{
  "type": "facebook or link or twitter or youtube"
}
spot-im-comment-label-clickedThe user has clicked one of the comments labels.

event
"event": {
  "detail": {
    "label": "LABEL_NAME",
    "message_type": "comment or reply",
    "parent_id": "PARENT_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-comment-reportedThe user has clicked to report a comment.

event
"event": {
  "detail": {
    "type": "comment or reply",
    "message_id": "MESSAGE_ID",
    "parent_id": "PARENT_ID",
    "reason": "REPORT_REASON_CHOSEN_BY_THE_USER_IF_THERE'S_ANY"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-current-user-sent-message-clickedThe user has clicked the Send button.

event
"event": {
  "detail": {
    "message_type": "comment or reply",
    "parent_id": "undefined or PARENT_ID",
    "labels": ["LABEL_NAME"]
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-current-user-sent-message-failedMessage sending failed.

event
"event": {
  "detail": {
    "message_type": "comment or reply",
    "parent_id": "undefined or PARENT_ID",
    "labels": ["LABEL_NAME"]
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-current-user-sent-message-succeedMessage sending succeed.

event
"event": {
  "detail": {
    "message_type": "comment or reply",
    "message_id": "MESSAGE_ID",
    "parent_id": "undefined or PARENT_ID",
    "labels": ["LABEL_NAME"]
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-current-user-typing-endThe user has focused out of the text editor field.

event
"event": {
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-current-user-typing-startThe user has focused on the text editor field.

event
"event": {
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-message-body-clickedThe user has clicked on the body of a message or reply.

event
"event": {
  "detail": {
    "type": "comment or reply",
    "message_id": "MESSAGE_ID",
    "parent_id": "PARENT_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-notification-preview-clickThe user has clicked the notification icon (bell icon).

event.detail
{
  "action": "close or open"
}
spot-im-notification-preview-showThe user has notifications.

event.detail
{
  "amount": NUMBER_OF_NOTIFICATIONS
}
spot-im-replies-list-toggledThe user clicked View X replies.

event
"event": {
  "detail": {
    "type": "comment",
    "message_id": "MESSAGE_ID",
    "replies_opened": BOOLEAN,
    "number_of_replies": NUMBER_OF_REPLIES_TO_THE_COMMENT
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-show-more-comments-clickedThe user has clicked Show More Comments.

event
"event": {
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-sort-by-selectThe user has selected a sorting option.

event
"event": {
  "detail": {
    "selected": "NEWEST_FIRST or OLDEST_FIRST or HOT"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}
spot-im-write-comment-focusThe user has focused the start of the conversation text editor.

event
"event": {
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}

Live Blog

EventDescription
spot-im-liveblog-loadedLive Blog has loaded.
spot-im-liveblog-message-visibleA message has become visible to the user in the Live Blog feed, through either initial load or scrolling.

event.detail
{
  "msg_id": "MESSAGE_ID"
}
spot-im-liveblog-new-message-pendingThe user received a notification about a new Live Blog post.
spot-im-liveblog-new-messages-scrolled The user scrolled (or Scrolled to Top) to consume Live Blog posts.
spot-im-liveblog-scroll-to-top-clicked The user clicked the Scroll To Top button.

Reactions

EventDescription
spot-im-comment-button-clickedThe user clicked the reaction or replied button.

event
"event": {
  "detail": {
    "action": "reply or vote or devote",
    "type": "comment or reply",
    "message_id": "MESSAGE_ID",
    "parent_id": "PARENT_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}

Topics

EventDescription
spot-im-clicked-tabThe user clicked on tab

event.detail
{
    "to": "CURRENT_TAB", 
    "from": "PREVIOUS_TAB"
}

User Profile

EventDescription
ow-open-custom-user-profileThe the user has clicked the View Profile button of a specific user or user image or user name.

event.detail
{
    "userId": "SSO_PRIMARY_KEY"
}
NOTE: To use this functionality, request custom user profile to be enabled from your OW PSM.
spot-im-clicked-article-link-profileThe user has clicked on an article from a user's history view. Event details include the article's URL.
spot-im-open-user-profileThe user has clicked the View Profile button of a specific user.

event
"event": {
  "detail": {
    "userId": "VIEWED_PROFILE_USER_ID"
  },
  "meta": {
    "spotId": "SPOT_ID", 
    "postId": "POST_ID", 
    "module": "ASSET_GENERATING_EVENT", 
    "host": "HTML_ELEMENT or null"
  }
}


Identity

EventDescription
spot-im-api-readyThis event listener notifies that the public API, such as SSO, is ready.
spot-im-login-start The user triggered a new log in process. For SSO implementations, listen to this event to show your login modal.
spot-im-signup-start The user triggered a new signup process. For SSO implementations, first ask your PSM to enable the signup button in the Conversation UI, then listen to this event to show your registration modal.
spot-im-post-loginA user logged in to the system. Fired once after a successful login process.

event.detail
{
    "currentUser": {
        "email": "USER_EMAIL",
        "socialNetworks": ["ARRAY_OF_NETWORKS"],
        "username": "USERNAME"
    }
}
spot-im-post-signupA new user signed up. Fired once after a successful email or social network signup process.

event.detail
spot-im-user-auth-successRegistered user authentication completed. Fires on every page load.

event.detail
{
    "email": "USER_EMAIL",
    "socialNetworks": ["ARRAY_OF_SOCIAL_NETWORKS"],
    "username": "USERNAME"
}
spot-im-user-logoutThe user initialized a log out process.


Popular in the Community

EventDescription
spot-im-recirculation-item-clickedThe user clicked a Popular in the Community item.

event.detail
{
    "url": "CLICKED_ITEM_URL",
    "title": "ARTICLE_TITLE"
}
spot-im-recirculation-left-clickedThe user clicked the left navigation arrow.
spot-im-recirculation-loadedThis event listener notifies that Popular in the Community has loaded.
spot-im-recirculation-right-clickedThe user clicked the right navigation arrow.
spot-im-recirculation-viewedThe user viewed Popular in the Community.


Reactions

EventDescription
openweb-reactions-votedThe user voted X times in the reactions module

event.detail
{
    "title": "QUESTION_ASKED", 
    "votedReaction": "REACTION_TO_QUESTION",
    "userId": "USER_ID",
    "category": "REACTION_CATEGORY",
    "score": TIMES_REACTION_CLICKED
}


Real Time

EventDescription
spot-im-realtime-new-messageA new message appeared in the Conversation or the Live Blog in real-time.

event.detail
{
    "source": "MESSAGE_SOURCE",
    "eventCode": "LIVE_BLOG_EVENTCODE",
    "postId": "CONVERSATION_POST_ID",
    "fromUser": {
       "id": "USER_ID",
       "username": "USERNAME",
       "displayName": "DISPLAY_NAME",
       "isReporter": LIVE_BLOG_BOOLEAN
    },
    "message": {
        "type": "MESSAGE_TYPE",
        "time": "JAVASCRIPT_TIMESTAMP"
    }
}
Possible fromUser.isReporter Values:
false
truePossible message.type Values:
comment
replyPossible source Values:
conversation
live-blog


Spotlight

EventDescription
spot-im-spotlight-CTA-clickThe user clicked the Comment button

event.detail
{
    "type": "SPOTLIGHT_TYPE", 
    "redirectUrl": "SPOTLIGHT_REDIRECT"
}
Possible type Values:
counter
form

Topic Tracker

EventDescription
spot-im-topic-tracker-tag-followedThe user clicked to follow a tag on the Topic Tracker widget

event.detail
{
    "name": "TAG_NAME", 
    "type": "TAG_TYPE"
}
Possible type Values:
keyword
author
spot-im-topic-tracker-tag-unfollowedThe user clicked to unfollow a tag on the Topic Tracker widget

event.detail
{
    "name": "TAG_NAME", 
    "type": "TAG_TYPE"
}
Possible type Values:
keyword
author