This method allows setting event handlers for each of the supported global events.

Description

The Gigya service generates several global application events for various situations that are driven by user interactions.
Global application events are fired whenever the event to which they refer occurs, regardless of what was the action that triggered the event.
This is in contrast to plugin events, which are only fired by the specific plugin on which they were configured.
This method allows setting event handlers for each of the supported global events.
To learn more about how to handle events generated by Gigya, see Events.

 

The following is a list of available global application events:

 

An Event Handler is a JavaScript function with the following signature:

functionName(eventObj)

The single argument eventObj, contains information about the event and has different data fields for different events. In "Event Handlers - eventObj event data" below, you will find the specification of the available fields in the eventObj for each event.

 

Note: Several social & sharing plugins may generate these global events. You may identify the source of the event using the 'source' field in the returned event data. Read more in the events' data reference below.
Please note that the plugins may trigger onConnectionAdded or onLogin depending on the  connectWithoutLoginBehavior  parameter of the global configuration object. Read more in the Using Plugins to Initiate Site Login guide.

 

 

RequiredNameTypeDescription
onLoginfunctionA reference to a function that is called when the user is successfully authenticated by Gigya.
onLogoutfunctionA reference to a function that is called when the user has logged out.
onConnectionAddedfunctionA reference to a function that is called when the user is successfully connected to a provider.
onConnectionRemovedfunctionA reference to a function that is called when the user disconnects from a provider.
callbackfunction
cidstring
contextobject

 

FieldTypeDescription

 

Event Handlers - eventObj Event Data

The following tables specify the list of available data fields in the eventObj for each event.

onLogin Event Data

FieldTypeDescription
eventNamestringThe name of the event: 'login'.
sourcestringThe source plugin that generated this event. The value of this field is the name of the plugin's API method, e.g. 'showLoginUI'.
Note: this field will not be available if the source of this event is not a plugin (e.g. if the source is a socialize.login API call).
contextobjectThe context object passed as a parameter to the plugin/method that triggered this event, or null if no object was passed.
loginModestringThe type of login:
  • standard  - the user is logging into an existing account.
  • reAuth  -  the user is proving ownership of an account by logging into it.
providerstringThe name of the provider that the user used in order to login (e.g. "Facebook"). Note: If this event is fired as a result of a socialize.notifyLogin call, i.e. the user was authenticated by your site, the provider field will be set to "site".
signatureTimestamp stringThe GMT time of the response in UNIX time format (i.e. the number of seconds since Jan. 1st 1970). The time stamp should be used for login verification, as described under the Validate the UID Signature in the Social Sign-On Process section.
UIDstringThe User ID that should be used for login verification*.
UIDSignature stringThe signature that should be used for login verification, as described under the Validate the UID Signature in the Social Sign-On Process section.
userUser objectUser object with updated information for the current user.
signature string Deprecated . Please use the UIDSignature parameter instead.
timestamp string Deprecated . Please use the signatureTimestampparameter instead.
This parameter holds the GMT time of the response in "yyyy-mm-dd HH:mm:ss" format where HH is in 24 hour time format.

* To learn more about login verification, please refer to the Validate the UID Signature in the Social Login Process section in the Security page of the Developer's Guide.

onLogout Event Data

FieldTypeDescription
eventNamestringThe name of the event: 'logout'.
contextobjectThe context object passed as a parameter to the plugin/method that triggered this event, or null if no object was passed.

  

onConnectionAdded Event Data

FieldTypeDescription
eventNamestringThe name of the event: 'connectionAdded'.
sourcestringThe source plugin that generated this event. The value of this field is the name of the plugin's API method, e.g. 'showCommentsUI', 'showChatUI', etc.
Note: this field will not be available if the source of this event is not a plugin (e.g. if the source is a socialize.addConnection API call)
contextobjectThe context object passed as a parameter to the plugin/method that triggered this event, or null if no object was passed.
userUser objectA User object with updated information for the current user.
providerstringThe name of the social network to which the user connected.

 

onConnectionRemoved Event Data

FieldTypeDescription
eventNamestringThe name of the event: 'connectionRemoved'.
sourcestringThe source plugin that generated this event. The value of this field is the name of the plugin's API method, e.g. 'showEditConnectionsUI'.
Note: this field will not be available if the source of this event is not a plugin (e.g. if the source is a socialize.removeConnection API call)
contextobjectThe context object passed as a parameter to the plugin/method that triggered this event, or null if no object was passed.
userUser objectUser object with updated information for the current user.
providerstringThe name of the social network from which the user disconnected.

  

onLinkBack Event Data

FieldTypeDescription
eventNamestringThe name of the event.
sourcestringThe source plugin that shared the link that led to the page.
contextobjectThe context object passed as a parameter to the method, or null if no object has been passed.
providerstringThe provider from which the linkback came.
cidstringThe context ID used for reports. Read more here.
shortCodestringThe original short URL code.

Code Sample

function DisplayEventMessage(eventObj) {
    alert(eventObj.eventName + " event happened");
}

gigya.socialize.addEventHandlers({ 
    onLogin:DisplayEventMessage,
    onConnectionAdded:DisplayEventMessage,
    onConnectionRemoved:DisplayEventMessage
   }
);