Thursday, April 7, 2011

Facebook "Like" and "Share" count same -- A work around

I have been writing a post here after so long. The thing made me write this is about facebook.
We had added facebook LIKE and share buttons to our site. The client posted a bug saying the count of LIKE and share buttons is always the same. After doing some googling I found facebook guys saying the count is of interaction of the link with facebook. For example we put it on and someone LIKE it, it will increment the interaction. Then if someone share it on facebook this will also increment the interaction.
I found the work around by chance. :)
Here it is.
FB Share button like the one below

<div class="dvshare" style="float: right; width: 120px;">

            <a href="" name="fb_share" type="button_count">Share</a><script
                src="" type="text/javascript">

It picks up the current URL from browser, share it and increments the count.
In my case the URL was like this

The browser automatically adds "/" at the end making it "".

The LIKE button however first look for the canonical tag and send canonical tag to facebook.

Fortunately we had added the canonical tag like this.

<link rel="canonical"  href="" /> i.e. without the "/" at the end.
This made it having different counts for share and LIKE button.
In my personal opinion it is a bug on facebook but.....
Happy coding...:)


  1. Thanks a lot! :-)

  2. You can get your website share count data in json format from Is free.