0

我目前正在使用 Gigya wordpress 插件在 Wordpress 中实现共享栏,但我需要能够跟踪共享事件并且我没有使用 Google Analytic。知道如何在此插件中添加回调以启用跟踪吗?我需要使用回调的原因是因为 google plus share 在 iframe 中,我无法绑定 click 事件。

我已阅读此文档,但这是使用与 wordpress 插件不同的 Gigya api。我试图使用这段代码,但它什么也没做。

// 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);
4

2 回答 2

3

我刚刚遇到了同样的问题,这就是我的做法。在设置 Gigya 分享按钮的某些时候,您必须声明一个名为“shareParams”的变量,在gigya.services.socialize.showShareUI(shareParams)中调用。

只需将'onSendDone' : yourFunctionName添加到 shareParams 对象。

例子:

var shareParams = {
    'userAction' : {0},
    'onSendDone' : myNamespace.GigyaSendDone
}

gigya.services.socialize.showShareUI(shareParams);

共享成功完成后,将调用此 Javascript 操作。

于 2013-08-20T16:20:18.093 回答
0

所以感谢 Emanuele Ciriachi,我在插件中找到了 js api 代码。一旦修改它,我认为这将解决我的问题。

于 2013-08-22T22:57:09.207 回答