The Social Login solution supports client-side handling of a number of events. These are useful for making customizations based on information gathered at run time, and for using third-party analytics to track specific events.

To handle events generated by Social Login, register your event handlers within the thejanrainWidgetOnload function. Each of the following event objects has an addHandler method that takes a single function reference as an argument. An event can have any number of handlers; each one is called when the event occurs.

The following examples show how to register event handlers. See the Janrain-Sample-Code Github repo for more. Here is a full example of using the Janrain event system to send data to a third-party analytics site such as Google Analytics.

Supported Events

The following fields in the object define events:

Object Description Event Handler
onModalWidgetReady Fires when the modal window is ready. None
onReturnExperienceFound Occurs when a user returns to the site after signing in previously and the UI presents itself in a simplified form. It assumes the user plans to sign in with the same provider and user name. An object containing the following fields:

  • returnProvider—A string identifying the identity provider previously used. Possible values are documented here.
  • welcomeName—The user’s name, as it appears in the “welcome back” message.
onProviderLoginStart Occurs when the user clicks the provider or return experience button, beginning the sign-in process. Object with single field indicating provider chosen.
onProviderLoginError Occurs when encountering an error during the sign-in process. An object containing the following fields:

  • err—Error object.
  • code—Numeric error code.
  • msg—Descriptive error string.
  • origin—Origin of sign-in error.
  • stat—Status message.

See JavaScript Error Codes for a list of possible return values.

onProviderLoginSuccess Occurs when the user successfully signs in. None
onProviderLoginComplete Occurs when the sign-in process is complete, whether successful or not. None
onProviderLoginToken Occurs when the user successfully signs in, and the tokenAction setting is true. A response object containing a single token field; this contains the one-time token.
onProviderLoginCancel Occurs when the end user clicks the Cancel or No Thanks button on the login screen. Some identity providers do not include a Cancel button or their cancel message does not get passed to Social Login. You may encounter issues with these providers:

  • AOL
  • Yahoo!
  • Flickr
  • Foursquare
  • Linkedin
  • Twitter
  • Verisign
  • LiveJournal
  • Disqus
  • Renren
  • Tumblr
  • WordPress
This event is fired from inside the cancelLogin call.
onProviderLogoutStart Fires when the user begins the sign-out process. Object with a single field (indicating provider).