Third Party Analytics

One of the features available in the Janrain Engage Javascript API is the ability to send data to popular third-party analytic sites, such as Google Analytics and Omniture SiteCatalyst. An administrator can use these analytical tools to gain greater insight into how users interact with the website.

The Javascript API fires events, which you can track and report as needed. The API provides fine grained data, based on user actions. Some common events you might wish to track are

  • onProviderLoginStart — This event marks a successful initiation of a sign-in.
  • onProviderLoginComplete — This event marks a successful or unsuccessful completion of a sign-in.
  • onProviderLoginSuccess — This event marks a successful completion of a sign-in.

To add third-party analytics tracking, use the Google or Omniture method calls to the JavaScript event.

Third Party Analytics Quick Start Guide

This example shows how to send profile data to Google Analytics every time a user completes a sign-in.

The events become available after the widget loads. The easiest way to do this is to use the janrainWidgetOnload callback function. Use this function to define the events to track, as well as the data to send.

  1. Invoke the janrainWidgetOnload function — See Code Sample 1, Line 1.
  2. Determine what event to track — In this case, we’re interested in the completion of a user sign-in, and so will use onProviderLoginComplete. See Code Sample 1, Line 2.
  3. Determine what third-party call to use — In order to integrate with Google Analytics, we need to use their API to return the data. According to their documentation, the trackEvent call will return the event data. See Code Sample 1, Line 3.
  4. Decide what data the event will send — Once the event is triggered, the arguments in the trackEvent call will define what data to return. For this example, we’d like the Category to appear as “Sign-in,” the Action as “loginComplete.” In addition, we’ll opt to further label the event as “providerName.” See Code Sample 1, Line 3.
  5. Insert the code — Now put all the pieces together and add to web page. Place this function in the <head> of the website, under the default widget script.

Code Sample 1

function janrainWidgetOnload() {
    janrain.events.onProviderLoginComplete.addHandler(function(response) {
        _trackEvent('Sign-in', 'loginComplete', response.provider);
    });
}

Every time a user action triggers the onProviderLoginComplete event on this page, the widget sends the requested data to Google Analytics for processing.

Note: You need to place this code in the <head> tag of each page that needs tracking.

The example above is a basic overview. You can set up any event to report to an external analytic site, offering a wide variety of data gathering and marketing solutions. Refer to our example site for more complex examples of integrations:

Help Us Improve!

Give us your feedback