addEventListener(event_type, callback)

Services events

This method can be used to listen for events related to the Kongregate user.

The addEventListener method takes two arguments, the event type, and a callback function:

NameTypeDescription
event_typeStringType of event to listen for
callbackFunctionFunction to call when the event is triggered

User events

The following event types are currently supported:

NameDescription
loginThe user has converted from a guest to a registered user. User info methods on the services object will return updated information after this event is triggered.

Example: Listen for user login event

kongregate.services.addEventListener("login", onKongregateInPageLogin);

function onKongregateInPageLogin() {
  var user_id = kongregate.services.getUserId();
  var username = kongregate.services.getUsername();
  var token = kongregate.services.getGameAuthToken();
}

Related: