I'm setting up a google+ share button, and want to know when someone has shared the link so that I can perform an action. You can register a callback on the share button using the onendinteraction
attribute, and the documentation states that this will be called whenever the share box is closed and whenever the share is completed.
My function is being called when the window is closed, but not when the link is actually shared:
function redirectGooglePlus(jsonParam) {
alert(jsonParam.type);
}
<div class="g-plus" data-action="share" data-annotation="vertical-bubble" data-height="60"
data-href="http://mywebsite.com" data-onendinteraction="redirectGooglePlus"></div>
My function redirectGooglePlus
is only ever called when the hover
type, and never confirm
(which is the one that is supposed to signify the share has been completed.
Does anyone know why the function isn't called with confirm
?
FYI the google share documentation is here: https://developers.google.com/+/web/share/
So this appears to be a bug with the current implementation of the google+ share button:
https://code.google.com/p/google-plus-platform/issues/detail?id=396
The (hideous) workaround I've used for now is to look for 2 hover events for the onendinteraction
. If the events come in quick succession (less than 1 second), then it's likely they've shared the item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With