Track Analytics Events

Learn how to track analytics events in your iOS app

The SPAnalyticsEventDelegate allows you to track analytics events.



Track Events

Use the following steps to track analytics events:

  1. Implement the SPAnalyticsEventDelegate protocol.
extension ViewController: SPAnalyticsEventDelegate {
    internal func trackEvent(type: SPAnalyticsEventType, event: SPAnalyticsEventInfo) {
        switch type {
        case .userProfileClicked:
            print("Spot.IM Analytics Event - " + event.eventType)
        // More types can be handled here ...
        default:
            print("Spot.IM Analytics Event - " + event.eventType)
        }
    }
}

  1. Add more events in the switch sentence, according to your requirements.

  2. Set self as SPAnalyticsEventDelegate.

SpotIm.setAnalyticsEventDelegate(delegate: self)


SPAnalyticsEventType Reference

SPAnalyticsEventType Event Action
appClosed app-closed App has moved to the background.
appInit app-initialized SDK has been initialized.
appOpened app-opened App has moved to the foreground.
CommentDeleteClicked comment-delete-clicked User clicked Delete in the comment's context menu.
commentPostClicked comment-post-clicked User clicked the Post button in the create comment screen.
commentRankDownButtonClicked comment-rank-down-button-clicked User clicked on the rank-down button.
commentRankDownButtonUndo comment-rank-down-button-undo User clicked on the selected rank-down button to undo ranking down a comment.
commentRankUpButtonClicked comment-rank-up-button-clicked User clicked on the rank-up button.
commentRankUpButtonUndo comment-rank-up-button-undo User clicked on the selected rank-up button to undo ranking up a comment.
commentReadLessClicked comment-read-less-clicked User clicked the Read Less button on a long message.
commentReadMoreClicked comment-read-more-clicked User clicked the Read More button on a long message.
CommentReportClicked comment-report-clicked User clicked Report in the comment's context menu.
commentShareClicked comment-share-clicked User clicked Share in the comment's context menu.
communityGuidelinesLinkClicked community-guidelines-link-clicked User clicked a link in the community guidelines.
createMessageClicked create-message-clicked User opened the create comment screen.
engineStatus engine_status Monetization events
hideMoreRepliesClicked hide-more-replies-clicked User clicked the Show Less Comments button.
loaded loaded Conversation loaded on the screen.
loadMoreComments load-more-comments-clicked More comments were loaded because the user tapped Show More Comments in the Pre-Conversation OR scrolled in the full Conversation.
loadMoreRepliesClicked load-more-replies-clicked User clicked the Show More Comments button.
loginClicked login-clicked User clicked on the login button.
mainViewed main-viewed Full Conversation is initially viewed by the user.
messageContextMenuClicked message-context-menu-clicked User clicked to open the comment's context menu.
messageContextMenuClosed message-context-menu-closed User closed the comment's context menu.
myProfileClicked my-profile-clicked User clicked on his or her own profile button.

This event returns the following extra data:
  • targetType: Indicates if profile-avatar or profile-user-name was clicked
reading reading Pre-Conversation has been closed.
sortByClicked sort-by-clicked User changed the sorting of the Conversation.
sortByOpened sort-by-opened User clicked on the sort drop-down.
userProfileClicked user-profile-clicked User clicked on the profile button of a specific user.

This event returns the following extra data:
  • targetType: Indicates if profile-avatar or profile-user-name was clicked
viewed viewed Conversation is initially viewed by the user.