Retrieving Share Counts for Custom Buttons

While we've designed the LinkedIn Share Plugin to work for almost every use case, there might occasionally be a situation where you need something custom. For example, if you need all of your social sharing buttons to be 30px wide, you'd need a smaller button than the one that we provide out-of-box. We always recommend that you use the real Share Plugin, but in the event that you can't, this article will show you how to display the correct share count to your users.

The LinkedIn Share Plugin

As a quick reminder, the best method to share your content with the LinkedIn community is to use our share plugin. The share plugin allows your users to easliy share your content with a single click from your website. As a publisher you get the added advantage that your readers have a recognizable icon for sharing your content with the largest professional network in the world, and adding your content to the LinkedIn Today Ecosystem extends the reach of your content and brings you new, engaged users.

All that is required on your part is to place a few lines of JavaScript code on your page.

<script src="" type="text/javascript"></script>
<script type="IN/Share" data-counter="top"></script>


Please go to the Share Plugin configuration page to generate your own plugin.

Using the JavaScript share count

If for some reason you can not use the button, then we have a JavaScript method that allows a developer to get the share count for a submitted URL. You can use this if you need a custom "share on LinkedIn" button, or if you are performing shares via the LinkedIn Share API and want to track shares. Using this call you can display the number of times the article was shared in a manner that makes sense for your button or site layout.


  1. Since the call to get the share count happens in the LinkedIn framework you need to load the LinkedIn JavaScript in your page. Please read the section on Configuration and Compatibility to understand how to initialize the framework.
  2. To query the LinkedIn servers for the document share count you simply call IN.Tags.Share.getCount(url, callback).
    1. URL represents the URL you want to get the share count for
    2. callback is a function name to handle the response from the LinkedIn server
  3. The LinkedIn server returns a single integer, which is the total number of shares for the URL. It is up to you to write a callback function that takes the number returned and displays it properly.

Reference Information

Share Count

IN.Tags.Share.getCount(url, callback)
  • url - {string} the url for which you want to query the number of LinkedIn shares
  • callback - the name of the function to call when the LinkedIn server returns the count. The callback will be passed an argument which is an integer and represents the number of shares of the url

Code example of getting the count for the number of times "" has been shared:

  <script type="text/javascript" src="">
    api_key: xxxxxxxxxxxx //put your API key here
  <script type="text/javascript">
    function testme(count){
        alert("That document has been shared: " + count + " times");
<body >
  <p>Sharing count</p>
  <button onclick='IN.Tags.Share.getCount("",testme);'>
    Get Count

The Countserv Endpoint

If, for security reasons, you can not load the LinkedIn JavaScript framework you can make a direct request to the share count endpoint to retrieve the count. Using the endpoint is as simple as sending the URL of interest and receiving back a small piece of JSON for you to process.

This endpoint is intended primarily for LinkedIn internal use and as such there is no guarantee about the stability of the URL or the permanence of its signature. Check back here for future changes.



Name Valid Values Description
url Any valid url string that starts with http(s) Required: The URL to be shared. It MUST be encoded if it contains any special characters, such as ? or #. Anything after the # for a page anchor is truncated
format A string with either json or jsonp Required: The format for the response. If you specify jsonp then you must provide the callback parameter
callback A string with the function name Optional (Required if format=jsonp): The name of the JavaScript function that will handle the results




  • "count" is the number of shares
  • "url" is the url requested




Keys and values have the same meaning as before but the JSON object is wrapped in a JavaScript function call.