Publishers can add event listeners (on client side) to aid in tracking engagement or for other functionality. Spot.IM has event listeners for multiple widgets.
Example: spot-im-current-user-sent-message
can be added to a script tag to trigger an event when a user sends a comment they have written. In this example below, event.detail will be logged to the console after the event is fired.
document.addEventListener('spot-im-current-user-sent-message', function(event) {
// event.detail includes information relevant to this event
console.log(event.detail);
});
Please note: It is advised that the <script> element is kept within the header. Any events that occurr before the listener registration will be lost. Make sure events are registered as early as possible, and before Spot.IM loads. Multiple events can be used within a single script tag.
Notifies that the public API, such as SSO, is ready.
The Conversation is loaded on the page.
The user has started typing a comment.
The user has finished typing a comment.
The user has clicked on the "Post" button.
The user has clicked on the profile dropDown menu. Event details include the details of the user.
The user has clicked on the "Settings" button in the profile context menu. Event details include the details of the user.
The user has clicked on the "Privacy" button. in the profile context menu.
The user has clicked on an article from a user's history view. Event details include the article's URL.
The user has clicked on the sort dropdown.
The user has changed the sorting of the conversation.
The user has opened the notification inbox.
The user has started to reply a comment on the conversation.
The user has clicked the "Like" button.
The user has clicked the "Disike" button.
The user has opened the list of likers. Event details include the comment's ID.
The user has clicked on the "Share" button
The user has chosen to share the comment on a specific option. Event details include which share option was chosen.
The user has clicked on the "Report" option.
The user has clicked on the "Show More Comments" button.
The user has clicked on the "Show More Replies" button. Event details include the parent ID of the replies.
The user has clicked on the "View Profile" button of a specific user. Event details include the User ID.
The user initialized a log in process.
The user has logged in to the system.
event.detail
:
{
currentUser: {
email,
socialNetworks: [],
username
}
}
The user initialized a log out process.
The user has clicked to up vote a comment.
The user has clicked to down vote a comment.
The user has clicked on the notifications icon (the bell icon).
The user has clicked on a Twitter or Instagram "Show" button in a comment (this occurs on mobile layout).
The iframe, which holds Spot.IM Conversation, was resized.
event.detail
:
{
height,
iframe,
type,
width
}
A user had triggered a modal opening. This event includes the height of the modal.
event.detail
:
{
height
}
The user opened the user profile screen.
event.detail
:
{
userId
}
A new message appeared in the Conversation or the Live Blog in real-time.
event.detail
:
{
source: 'live-blog' [or:] 'conversation',
// eventCode and postId are mutually exclusive
// if source="live-blog":
eventCode: '...live blog eventCode...',
// if source="conversation":
postId: '...conversation postId...',
fromUser: {
// common to live-blog and conversation
id: '...Spot.IM user ID',
username: '...username...',
displayName: '...display name (can be null)...',
// only for source="live-blog":
isReporter: true [or:] false
},
message: {
type: 'comment' [or] 'reply',
time: 'JS timestamp...'
}
}
The user has clicked on any object on the page with the a "spot-im-class" attribute.
event.detail
:
{
elementTop,
spotImClass
}
Spot.IM has added Javascript listeners to the Popular-in-the-Community Widget.
Recirculation item click
Left navigation arrow click
Right navigation arrow click
Recirculation loaded
Recirculation viewed
Spot.IM has added Javascript listeners to the Spotlight Widget.
The user has clicked on the Comment button.
event.detail
:
{
type,
referrerUrl
}
<script>
document.addEventListener('spot-im-post-login', function(event) {
var currentUser = event.detail.currentUser; // currentUser contains details about logged in user
console.log(currentUser.username + ', ' + currentUser.email + ', ' + currentUser.socialNetworks.join(' | '));
});
</script>