Contact Us
  • LinkedIn Share Button: Add it to your Website and Track Clicks with Google Analytics

    If you’re NOT on the HyperArts Blog, click here!

    NOTE: There have been issues with the LinkedIn Share Button tracking registering a share on each page load, without the user ever clicking the button. However, this appears to have been resolved. BUT it still seems that I’m getting more LinkedIn Shares showing up in my Google Analytics than are actually occuring. I’d love to hear from others about this.

    In my article Tracking Social Interactions with Google Analytics, I showed how to have social actions (send, share, etc.) tracked in your Google Analytics account (using the NEW version of Analytics and the asynchronous tracking code).

    You can now track LinkedIn Share button clicks with Google Analytics

    It’s pretty easy. Here’s how….

    First, get the LinkedIn Share button code

    You can get the code for your LinkedIn Share button on the Publisher page. Below, for example, is the code for the having the counter to the right of the button:

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

    You can change the “data-counter” variable to reflect your preference for where the counter appears or if it appears at all, as shown below:

    LinkedIn Share Button

    • Display above the button: data-counter=”top”;
    • Display to the right of button: data-counter=”right”;
    • No counter displayed: just omit the data-counter variable completely.

    Now you need to add an additional parameter to the code LinkedIn provides in order to trigger the Google Analytics when the user shares your content via the LinkedIn Share Button: data-onsuccess="LinkedInShare".

    Place the resulting code:

    <script type="IN/Share" data-counter="right" data-onsuccess="LinkedInShare"></script>

    within the <body> ... </body> tags of your file, where you want the LinkedIn Share Button to appear.

    Add JavaScript to your file to make it work

    Now you’ll see the purpose of the data-onsuccess="LinkedInShare" you added to the provided Share Button code.

    The following JavaScript — the “LinkedInShare” function — should be placed within the <head> tag of your file, preferably after the JavaScript that calls the Google Analytics JavaScript (ga_social_tracking.js):

    <!-- Google Analytics Social Button Tracking -->
    <script type="text/javascript" src="/js/ga_social_tracking.js"></script>
    <!-- LinkedIn Share Button tracking-->
    <script type="text/javascript">
    function LinkedInShare() {
    _gaq.push(['_trackSocial', 'LinkedIn', 'Share']);

    NOTE: Read my Google Analytics Social Tracking article for more detail on adding the ga_social_tracking.js file.

    Viewing your tracking results in Google Analytics

    As mentioned in my other posts on this topic, you MUST use the “New Version” of Google Analytics in order to track social clicks.

    Also, you MUST use the “asynchronous” tracking code on your site, replacing the old version completely.

    NOTE: You can read my previous post on setting up the new Google Analytics and getting your asynchronous tracking code.

    To view your tracking metrics, click: Visitors > Social > Engagement (or Pages or Actions).

    Your results, if your tracking is properly set up, will look similar to this:

    LinkedIn Share Button stats

    What I’ve learned from tracking LinkedIn Share button clicks

    The most amazing thing that became immediately apparent was just how many were using the LinkedIn Share button. Even more than they are using the Like Button.

    I also noticed that Google +1 seems, at least on our blog, to be in third place in terms of use.

    I was also surprised by the number of Facebook “unlikes” … It appears people use this function much more than I thought. I’m puzzled by that number and not sure what’s at work there.

    I’d like to hear from you, in the comments, about your experiences with Google Analytics social tracking.



    1. check your code, there is a bug for sure. Every time I load your page, a tracking call to linkedin tracksocial is made. So 5 page refreshes = 5 Linkedin share in your Google Analytics.

      You can check this issue with Fiddler or another HTTP header inspector

    2. Robert Miras says:

      Hi! I have read your article and found it really informative. I haven’t understand all of the things yet but for sure this will be a great help on improving my LinkIn account. I would be glad to bookmarked this page and read other articles related to this. Anyway, just I thought you might interest on this, I have leave a link for you to check out. Thanks.

      coin counters

    3. The Linked IN share button is one I was not yet familiar with. I have Plus One and Like buttons on most of my sites. I’ll check this out today – thanks!

    4. Aaron Lorentz says:

      Have you actually gotten the LinkedIn callback to fire?  I tested your page, and the LinkedIn callback does not fire.

      Also, Twitter share did not fire either, but I think that is due to the
      extractParamFromUri function, which I tested elsewhere. It doesn’t parse the URI properly, perhaps due to Twitter changing the URL format.

      • LinkedIn definitely fixed the issue, and they reworked their page on adding the code.
        My LinkedIn Share stats in Google Analytics appear to be accurate.

        • Aaron Lorentz says:

          The onsuccess callback for LinkedIn doesn’t appear to fire.  Their documentation is not accurate from what I’ve seen.  I’ve also read elsewhere that there’s been little success using the onsuccess callback.  I tested your site in Firebug, but the callback did not fire.  Perhaps the tracking you mention in GA is for something else on your site.  Just wanted to mention it, in case it wasn’t working for you.  Best.

          • I’m tracking clicks on the LinkedIn Share button with GA, and successfully. I’m not sure about the callback and how it plays into it. I do know they overhauled the button and changed the code for implementing it.
            Their code is now:

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

            with this in the <head>:

            <script type=”IN/Share” data-success=”LinkedInShare”></script> <script type=”text/javascript”>
            function LinkedInShare() {
            _gaq.push([‘_trackSocial’, ‘LinkedIn’, ‘Share’]);

            And it’s working. Go figure….

    5. Kiranrathod says:

      How I can track who has shared my blog posts or my links on linkedin??

    Speak Your Mind