Gigya Job Openings

Tracking Social Events

Skip to end of metadata
Go to start of metadata

 

Gigya's Web SDK fires events to which you can listen, and reports these events to your analytics provider. Please refer to the Events guide, which shows how to handle events generated by Gigya.

The sample code on this page shows yow to track social events and send them to Google Analytics. Generic skeleton code is also provided (in the "Other") tab for use with other analytics providers.

How to Track User Login Events

Gigya generates the following global events: onLogin, onLogout,  onConnectionAdded, and onConnectionRemoved
Register to the events that you would like to track. In the event handler method report the event to your analytics provider:

 

Google Analytics

// Register to Gigya events
gigya.socialize.addEventHandlers({ 
        onLogin: trackLoginEvent  // call trackLoginEvent when Social Login finishes successfully
  }
);

// trackLoginEvent - event handler
function trackLoginEvent(event) {
	var action = event.eventName + ": " +  event.provider;
        // Report the event to Google Analytics using the trackEvent method 
        _gaq.push(['_trackEvent', 'Gigya Social Login', action, document.title]);
}

 

How to Track Sharing Events

Share Bar

The Share Bar plugin generates the following events:

  • onSendDone - when the sharing process completes successfully.

Register to the events that you would like to track. In the event handler method report the event to your analytics provider:

 

Google Analytics

// onSendDone - event handler method, called after Gigya finishes the sharing process
// Reports the event to Google Analytics
function onSendDone(event) {
    if(event.providers) {
      var providers = event.providers.split(",");
      for(i = 0; i < providers.length; i++) {
           var provider = providers[i];

           // Report the event to Google Analytics using the trackSocial method
           _gaq.push(['_trackSocial',provider,"Share Published", document.title]);
      }
    }
}

var ua = new gigya.socialize.UserAction();
ua.setLinkBack("http://vimeo.com/24400434");
ua.setTitle("Changing Education Paradigm by Sir Ken Robinson");

// Define Share Bar plugin's Parameters  
var shareBarParams ={
        userAction:ua,
        shareButtons: "share, email, twitter-tweet, google-plusone, facebook-like",
        containerID: 'divButtons' // location of the Share Bar plugin,
        onShareButtonClicked: onShareButtonClicked, // onShareButtonClicked method is called when one of the plugin's buttons is clicked
        onSendDone: onSendDone // onSendDone method is called after Gigya finishes the publishing process.
};

// Load Share Bar plugin
gigya.socialize.showShareBarUI(shareBarParams);

 

Share

The Share plugin generates the following events:

  • onLoad - when a share plugin appears on screen.
  • onSendDone - when the sharing process completes successfully.

Register to the events that you would like to track. In the event handler method report the event to your analytics provider:

 

Google Analytics

// onLoad - event handler method, called when the plugin has finished drawing itself.
// Reports the event to Google Analytics
function onLoad(event) {
         // Report the event to Google Analytics using the trackEvent method
        _gaq.push(['_trackEvent', 'Gigya Share','Share Dialog Loaded', document.title]);
}

// onSendDone - event handler method, called after Gigya finishes the sharing process.
// Reports the event to Google Analytics
function onSendDone(event) {
    if(event.providers) {
      var providers = event.providers.split(",");

      for(i = 0; i < providers.length; i++) {
           var provider = providers[i];
           // Report the event to Google Analytics using the trackSocial method                       
           _gaq.push(['_trackSocial',provider,"Share Published", document.title]);
      }
    }
}

var ua = new gigya.socialize.UserAction();
ua.setLinkBack("http://vimeo.com/24400434");
ua.setTitle("Changing Education Paradigm by Sir Ken Robinson");

// Define Share plugin's Parameters  
var shareParams ={
        userAction:ua,
        containerID: 'divButtons' // location of the Share Bar plugin,
        onLoad: onLoad, // onLoad method is called when the plugin has finished drawing itself.
        onSendDone: onSendDone // onSendDone method is called after Gigya finishes the publishing process.
};

// Load the Share plugin
gigya.socialize.showShareUI(shareParams);

 

How to Track Reaction Events

The Reactions plugin generates the following events:

  • onReactionClicked, onReactionUnclicked - when a reaction button is clicked/unclicked.
  • onSendDone - when the sharing process completes successfully.

Register to the events that you would like to track. In the event handler method report the event to your analytics provider:

 

Google Analytics

// onReactionClicked - event handler method, called when one of the Reaction plugin's buttons is clicked
// Reports the event to Google Analytics
function onReactionClicked(event) {
        var reaction = event.reaction.text;
        // Report the event to Google Analytics using the trackEvent method
        _gaq.push(['_trackEvent', 'Gigya Reaction Bar', reaction + ' Reaction Button Clicked', document.title]);
}

// onSendDone - event handler method, called after Gigya finishes the sharing process.
// Reports the event to Google Analytics
function onSendDone(event) {
    if(event.providers) {
      var providers = event.providers.split(",");
      for(i = 0; i < providers.length; i++) {
           var provider = providers[i];
           // Report the event to Google Analytics using the trackSocial method                       
           _gaq.push(['_trackSocial',provider,"Share Published", document.title]);
      }
    }
}

// Define an array of reaction objects
var textReactions=[
     {
        text: 'Inspiring',
        ID: 'inspiring',
        iconImgUp:'http://cdn.gigya.com/gs/i/reactions/icons/Inspiring_Icon_Up.png',
        iconImgOver:'http://cdn.gigya.com/gs/i/reactions/icons/Inspiring_Icon_Down.png',
        tooltip:'This item is inspiring',
        feedMessage: 'Inspiring!',
        headerText:'You think this post is inspiring,'
     }
    ,{
        text: 'Geeky',
        ID: 'geeky',
        iconImgUp:'http://cdn.gigya.com/gs/i/reactions/icons/Geeky_Icon_Up.png',
        iconImgOver:'http://cdn.gigya.com/gs/i/reactions/icons/Geeky_Icon_Down.png',
        tooltip:'This item is geeky',
        disabledTooltip:'You found this geeky',
        feedMessage: 'This is geeky!',
        headerText:'You think this is geeky,'
     }
];

var defaultUserAction = new gigya.socialize.UserAction();
defaultUserAction.setTitle("This is the post title");
defaultUserAction.setLinkBack("http://www.gigya.com");

var reactionParams ={
        barID: 'today-story', //  Identifier of the content to which this reaction refers       
        containerID: 'reactionsDiv',  // Reactions Plugin DIV Container
        reactions: textReactions,  // The reaction array from Step 1
        userAction: defaultUserAction,  // The UserAction object from Step 2
        bodyText: 'Share it with your friends:', // optional - text that appears in the Share popup
        showCounts: 'top', // optional - displays the counters on top of the buttons
        onReactionClicked: onReactionClicked, // onReactionClickedmethod is called when one of the plugin's buttons is clicked
        onSendDone: onSendDone // onSendDone method is called after Gigya finishes the publishing process.
};

// Load the Reactions Plugin:
gigya.socialize.showReactionsBarUI(reactionParams);

 

How to Track Comments Events

The Comments plugin generates the following events:

Register to the events that you would like to track. In the event handler method report the event to your analytics provider:

 

Google Analytics

// onCommentSubmitted - event handler method, called when when a comment is submitted
// Reports the event to Google Analytics
function onCommentSubmitted(event) {
     // Report the event to Google Analytics using the trackEvent method
    _gaq.push(['_trackEvent', 'Gigya Comments','Comment Submitted', document.title]);
}

var params =
{
     categoryID:7623701,
     containerID: 'commentsDiv',
     onCommentSubmitted: onCommentSubmitted // onCommentSubmitted function is called when a comment is submitted
};

// Load the Comments Plugin
gigya.comments.showCommentsUI(params);

Note: You might notice that different analytics providers may report different analytics values. There are various reasons for that, you may find some of them in the following links:
http://www.google.com/analytics/support/index.html
http://stackoverflow.com/questions/8817903/why-do-facebook-insights-and-google-analytics-report-different-visitor-counts