How to create a custom Facebook, Twitter and Google Plus share button with a custom counter

Hi guys, in this tutorial I will explain to you how you can create a custom Facebook, Twitter, Linkedin and Facebook share button with a custom counter. You will be able to use this button whenever you like to share different url.

If you want to create a a share button for Facebook, use this code:

<a href="http://www.facebook.com/sharer.php?u=yoururl"><input name="Share to Facebook" type="button"></a>

If you want to create a a share button for Google Plus, use this code:

<a href="https://plus.google.com/share?url=yoururl"><input name="Share to Google Plus" type="button"></a>

If you want to create a a share button for Twitter, use this code:

<a href="https://twitter.com/share?url=yoururl"><input name="Share to Twitter" type="button"></a>

If you want to create a a share button for Linkedin, use this code:

<a href="https://www.linkedin.com/shareArticle?mini=true&url=yoururl"><input name="Share to Linkedin" type="button"></a>

If you like to count clicks on links, you can use jQuery. Add a id to your url.

<a href="http://www.facebook.com/sharer.php?u=yoururl" id="facebook">

jQuery(document).ready(function(){

jQuery("#facebook").click(function(){

jQuery.post("countfile.php", function(data) {

 

});

});

});

In this way you can create a custom Facebook, Twitter, Linkedin and Facebook share button with a custom counter.

I hope you know to use jQuery and PHP.









Leave a Comment