varsocialCount=function(social,cname,url){varvname=cname.replace(/-/g,"");if((newFunction('return (typeof '+vname+'!= "undefined");'))())return;(newFunction('window.'+vname+' = "defined";'))();url=(url)?encodeURI(url):encodeURI(location.href);socialData={type:'GET',dataType:'jsonp',data:{noncache:newDate().getTime()},always:function(data){timing.end=(newDate()).getTime();vart=timing.end-timing.start;ga('send','timing','social',social,t);}};if(social=='hatebu'){if('https:'==document.location.protocol){socialData.url="//query.yahooapis.com/v1/public/yql";socialData.data.q="SELECT content FROM data.headers WHERE url='http://api.b.st-hatena.com/entry.count?url="+url+"'";socialData.data.format="text";socialData.data.env="http://datatables.org/alltables.env";socialData.success=function(data){$('.'+cname).text(data.query.results.resources.content||0);};}else{socialData.url='http://api.b.st-hatena.com/entry.count';socialData.data.url=url;socialData.success=function(data){$('.'+cname).text(data||0);};}}else{return;}$.ajax(socialData);$('.'+cname).on('click',function(){ga('send','event','button','click',cname);});}
このJavaScriptを読み込んでおいて
12345678910
<divclass="share-button"><ul><li><ahref="http://b.hatena.ne.jp/entry/http://rcmdnk.github.io/blog/2014/12/15/blog-octopress/"title="Save to Hatebu"target="_blank"><pclass="hatebu_custom">B! <spanclass="hatebuCountblog-2014-12-15-blog-octopress"></span></p></a></li></ul></div><scripttype="text/javascript">socialCount('hatebu','hatebuCountblog-2014-12-15-blog-octopress','http://rcmdnk.github.io/blog/2014/12/15/blog-octopress/');</script>