Google +1, share, javascript callback

Google plus button, you can set a callback attribute to a js function,

<g:plusone href="" 

In the callback js function, you can check the state, if they have clicked +1 or removed +1.

    function plusClick(data) {
        if (data.state == "on") {
            // +1
        } else if (data.state == "off") {
            // -1 (user took their +1 Away)
    (function () {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

There are some other js callback as well, such as onstartinteraction (when the +1 dialog popups up), onendinteraction (when +1 dialog close).

For more information, check out this google page,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s