Getting Social share count with jQuery

Knowing social status of your online campaigns, blogs or websites is very important from marketing perspective. You must know how much your URLs  being liked or shared across social media like Facebook, LinkedIn, Twitter, Disqus (commenting system) and so on. Knowing stats & social health of your campaigns, blogs or websites can help you in visualizing the interest of your target audience or customers and how effectively you are able to make them engaged with your online presence through campaigns, blogs or websites and this can further be help you in devising future course of actions & strategize to stay connected with them.

Here are some of method to get social counters (share & likes) across various social media channels:

Facebook
//Fetch counters from Facebook
var fb_share_count = 0;
var fb_like_count = 0;
//SampleUrl is the concerned Url of your campaign, blog or website
FBUrl = "http://api.facebook.com/restserver.php?method=links.getStats&urls=" + SampleUrl + "&format=json"
$.getJSON(FBUrl, function(data) {
	fb_share_count = data[0].share_count.toString();
	fb_like_count = data[0].like_count.toString();
	console.log('Facebook share count:' + fb_share_count);
	console.log('Facebook like count:' + fb_like_count);
});
Twitter
 //Fetch counters from Twitter
var tw_share_count = 0;
//SampleUrl is the concerned Url of your campaign, blog or website
TWUrl = "http://cdn.api.twitter.com/1/urls/count.json?url=" + SampleUrl + '&callback=?'
$.getJSON(TWUrl, function(data) {
    tw_share_count = data.count.toString();
    console.log('Twitter share count:' + tw_share_count);
});
LinkedIn
 //Fetch counters from LinkedIn
var ln_share_count = 0;
//SampleUrl is the concerned Url of your campaign, blog or website
LNUrl = "http://www.linkedin.com/countserv/count/share?url="+ SampleUrl + "&format=jsonp" + '&callback=?'
$.getJSON(LNUrl,function(data) {
    ln_share_count = data.count.toString();
    console.log('LinkedIn share count:' + ln_share_count);
});
Disqus
 //Fetch counters from Disqus
var urlArray = [];
//SampleUrl is the concerned Url of your campaign, blog or website
urlArray.push('link:' + SampleUrl);
$.ajax({
    type: 'GET',
    url: "https://disqus.com/api/3.0/threads/set.jsonp",
    data: { api_key: disqusPublicKey, forum : disqusShortname, thread : urlArray},
    cache: false,
    dataType: 'jsonp',
    success: function (result) {
        console.log("Comment count: " + result.response[0].posts);
    }
});
Tumblr
 //Fetch counters from Tumblr
var tblr_notes_count = 0;
TblrUrl = "http://api.tumblr.com/v2/blog/<tumblr blog-name>/posts/text?api_key=<your api key>&filter=text&id="+post_id+"&callback=?"
$.getJSON(TblrUrl, function(data) {
    tblr_note_count = data.response.posts[0].note_count;
    console.log('Tumblr note count:' + tblr_note_count);
});

Visit free online tool Social Health Checker for reference.

(Visited 78 times, 1 visits today)