您還可以使用onShareButtonClicked事件做一些與供應商的名稱。請注意,這不適用於本地登錄按鈕(手機上的Google/Facebook),但如果您在網絡上進行操作,則應該按照您的需要進行操作。我附上了一個工作示例(需要頁面上有Gigya API密鑰)。
// Create a div for the widget (or use an existing div on your page)
var newShareDiv = document.createElement('div');
newShareDiv.id='ShareDiv';
newShareDiv.setAttribute('style', 'position: absolute; z-index: 1000; margin: 0px auto; margin-top: 10px !important; width: 200px; height: 20px; background-color: yellow; border: 2 px solid red;')
document.body.appendChild(newShareDiv);
//
// Create the UserAction for sharing
var gigyaShareAction = new gigya.socialize.UserAction();
gigyaShareAction.linkBack = 'https://demo.gigya.com';
gigyaShareAction.userMessage = 'Check this out!';
//
// Define shareButtons
var shareButtons = 'Facebook, Twitter, LinkedIn, Messenger, share';
//
// Define the Share Bar Plugin's params object
var shareParams = {
userAction: gigyaShareAction,
showCounts: 'none',
containerID: 'ShareDiv',
scope: 'both',
privacy: 'public',
iconsOnly: true,
layout: 'horizontal',
noButtonBorders: false,
operationMode: 'simpleShare',
onShareButtonClicked : function(e) {
console.log(e.shareItem.provider);
},
shareButtons: shareButtons // list of providers
};
//
// Load the Share Bar Plugin:
gigya.socialize.showShareBarUI(shareParams);
這將登錄到控制檯被點擊的供應商的名稱,則可以選擇創建一個變種,然後某處發送,或觸發與數據的谷歌分析事件。