I would like to know how to get the value for the +1 value((if there are 10 clicks +1 button, store 10 as a variable). This would be helpful for analysis purposes. I know the count parameter is only Boolean or plusone.state re开发者_JAVA技巧turns on/off but is there something like plusone.value? ( i tried it, it's undefined)
Thanks
Download the following url: https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url=URLENCODED_URI
via your favorite automatic method (curl, wget, file_get_contents, etc...)
URLENCODED_URI
is the site you which to know the number of +1's for, e.g. http://www.google.com
For example, fetch the URI https://plusone.google.com/u/0/_/%2B1/fastbutton?count=true&url=http://www.google.com/
and locate the first occurance of window.__SSR = {'c': 32414.0 ,'si'
. Preferably use regexp for this, but I'll leave the implementation to you and your chosen programming language.
The float number following 'c' is the number of +1's the site have. For google.com this is 32.414. Don't worry about it being a float, it is allways an integer in float format, so you can safely convert it to an integer.
There is an undocumented API for this described here - http://www.tomanthony.co.uk/blog/google_plus_one_button_seo_count_api/
Directions for +1 button tracking can be found at http://yoast.com/plus-one-google-analytics/
On the button creation screen, create a js callback then track the clicks using Google analytics with the following code:
<script type="text/javascript">
function plusone_vote( obj ) {
_gaq.push(['_trackEvent','plusone',obj.state]);
}
</script>
Alternately, use the javascript callback to track it any way you wish.
精彩评论