callbackgoogle-plustrackinggigya

How to add google+ share callback in Gigya Wordpress plugin?


I am currently using Gigya wordpress plugin to implement the share bar in Wordpress but I need to be able to track the share event and I am not using Google Analytic. Any idea how I can add a callback in this plugin to enable tracking? The reason I need to use a callback is because google plus share is in an iframe and I can't bind the click event.

I've read this documentation but this is using the Gigya api which is different than the wordpress plug. I tried to use this piece of code and it is not doing anything.

// onSendDone - event handler method, called after Gigya finishes the sharing process
// Reports the event to your Analytics provider
function onSendDone(event) {
    console.log('click');
    if(event.providers) {
      var providers = event.providers.split(",");
      for(i = 0; i < providers.length; i++) {
           var provider = providers[i];
           // Report the event to your Analytics provider
           //waTrackPlusOne_vote(provider);
           console.log('pass in ' + provider);
      }
    }
}

var ua = new gigya.services.socialize.UserAction();
var currentURL = window.location.href;
var $currentTitle = $j('title').text();
ua.setLinkBack(currentURL);
ua.setTitle($currentTitle);
// Define Share Bar plugin's Parameters  
var shareBarParams ={
        userAction:ua,
        shareButtons: "google-plusone",
        containerID: '.gig-button-container-google-plusone', // location of the Share Bar plugin,
        onSendDone: onSendDone // onSendDone method is called after Gigya finishes the publishing process.
}
// Load Share Bar plugin
gigya.services.socialize.showShareBarUI(shareBarParams);

Solution

  • I have just faced the same problem, here it's how I've done it. At some points when setting up the Gigya Share Button you will have to declare a variable called "shareParams", invoked in gigya.services.socialize.showShareUI(shareParams).

    Just add 'onSendDone' : yourFunctionName to the shareParams object.

    Example:

    var shareParams = {
        'userAction' : {0},
        'onSendDone' : myNamespace.GigyaSendDone
    }
    
    gigya.services.socialize.showShareUI(shareParams);
    

    When the sharing is successfully completed, this Javascript action will be invoked.