94

I need to be able to add sharing functionality to my custom button. I'm not interested with their generator, as I can't change LinkedIn image there. I want to use my own image for the LinkedIn share button.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Karol
  • 7,803
  • 9
  • 49
  • 67
  • 2
    They don't want you to make a custom button. Indeed, their Terms of Service probably prohibits it because they want their buttons to look like their buttons. – msw May 23 '12 at 04:44
  • But isnt there any method like with Twitter, that you can share using only the link? And then user is redirected to the page where he only needs to confirm... – Karol May 23 '12 at 08:07
  • how about a custom LinkedIn signin button? – DevDave May 13 '13 at 13:32
  • 1
    Please bear in mind that if your site is not accessible by LinkedIn any URL based methods won't work. This includes if it's behind a BasicAuth wall – Matt Fletcher Nov 19 '19 at 11:49

9 Answers9

170

Official LinkedIn API for sharing:

https://developer.linkedin.com/docs/share-on-linkedin

Read Terms of Use!

Example link using "Customized URL" method: http://www.linkedin.com/shareArticle?mini=true&url=https://stackoverflow.com/questions/10713542/how-to-make-custom-linkedin-share-button/10737122&title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=stackoverflow.com

You just need to open it in popup using JavaScript or load it to iframe. Simple and works - that's what I was looking for!

EDIT: Video attached to a post:

I checked that you can't really embed any video to LinkedIn post, the only option is to add the link to the page with video itself.

You can achieve it by putting YT link into url param:

https://www.linkedin.com/shareArticle?mini=true&url=https://www.youtube.com/watch?v=SBi92AOSW2E

If you specify summary and title then LinkedIn will stop pulling it from the video, e.g.:

https://www.linkedin.com/shareArticle?mini=true&summary=youtube&title=f1&url=https://www.youtube.com/watch?v=SBi92AOSW2E

It does work exactly the same with Vimeo, and probably will work for any website. Hope it will help.

EDIT 2: Pulling images to the post:

When you open above links you will see that LinkedIn loads some images along with the passed URL (and optionally title and summary).

LinkedIn does it automatically, and you can read about it here: https://developer.linkedin.com/docs/share-on-linkedin#opengraph

It's interesting though as it says:

If Open Graph tags are present, LinkedIn's crawler will not have to rely on it's own analysis to determine what content will be shared, which improves the likelihood that the information that is shared is exactly what you intended.

It tells me that even if Open Graph information is not attached, LinkedIn can pull this data based on its own analysis. And in case of YouTube it seems to be the case, as I couldn't find any Open Graph tags added to YouTube pages.

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Karol
  • 7,803
  • 9
  • 49
  • 67
  • 6
    Is there any way to seed the text area with text? I tried a bunch of different parameters, couldn't get anything to work. – Raphael Oct 21 '13 at 19:08
  • 2
    Not really @raphaelcm - in the new API you can add summary text, but it will not show up in textarea. – Karol Nov 26 '13 at 00:00
  • Thanks @Carlos for this answer .It helped me alot. Is it possible to embed video in shared post in linkedin? I was trying setting og:video meta tag .But it does'nt seems to be working? Can you help me with this? – alwaysLearn Jun 16 '14 at 09:36
  • You can set only whatever is in official documentation. I checked it for you and edited my answer. The only option is to put the direct link to the website containing your video. – Karol Jun 16 '14 at 22:47
  • This opens in a new page. Does it revert back to the previous page after posting? If no, is there a way to automate that as well? – GothamCityRises Jul 29 '14 at 14:01
  • 1
    The example link should be opened in popup window - this way after sharing you close the popup and stay on the website, e.g. http://stackoverflow.com/a/14352248/571230 – Karol Jul 30 '14 at 01:12
  • 1
    I noticed that this method does not necessarily respect the `og:image`, while simply dropping the URL in a new LinkedIn post does. Does anyone know why that would be? – ACJ Feb 06 '18 at 14:29
  • @ACJ just noticed that my links were outdated and pointed to YouTube clip which didn't exist. I edited them and I can see images being pulled in. – Karol Feb 07 '18 at 04:49
  • @ACJ did some reading and edited my answer to talk a bit about those og tags. – Karol Feb 07 '18 at 04:54
  • 1
    Thanks @Karol, but we already did all that. When I paste a URL from our website in a new LinkedIn post, it always gets the relevant image from our OpenGraph tags, but when I click the LinkedIn share button on our website, it never gets the image (or any other). I get the impression this is actually a LinkedIn bug. – ACJ Feb 07 '18 at 10:35
  • 1
    Agreed, must be a bug. Wondering if there is a way to report it... Hope you're gonna solve it! – Karol Feb 07 '18 at 10:44
  • 4
    Docs are updated now, with new API: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin?context=linkedin/consumer/context – Himanshu Aggarwal Feb 18 '19 at 15:30
  • 18
    The `/shareArticle` URL no longer functions as it used to. It redirects to `https://www.linkedin.com/sharing/share-offsite/?url=...`, losing the other arguments. – Phil Gyford Nov 21 '19 at 11:50
  • Now it seems /sharing/share-offsite isn't working either. – Archonic Sep 16 '21 at 23:10
67

You can make your own sharing button using the LinkedIn ShareArticle URL, which can have the following parameters:

https://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}

You can find the documentation here, just choose "Customized URL" to see the details.

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Tamer Shlash
  • 9,314
  • 5
  • 44
  • 82
56

Step 1 - Getting the URL Right

Many of the answers here were valid until recently. For now, the ONLY supported param is url, and the new share link is as follows...

https://www.linkedin.com/sharing/share-offsite/?url={url}

Make sure url is encoded, using something like fixedEncodeURIComponent().

Source: Official Microsoft.com Linkedin Share Plugin Documentation. All LinkedIn.com links for developer documentation appear to be blank pages now -- perhaps related to the acquisition of LinkedIn by Microsoft.

Step 2 - Setting Custom Parameters (Title, Image, Summary, etc.)

Once upon a time, you could use these params: title, summary, source. But if you look closely at all of the documentation, there is actually still a way to still set summary, title, etc.! Put these in the <head> block of the page you want to share...

  • <meta property='og:title' content='Title of the article"/>
  • <meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
  • <meta property='og:description' content='Description that will show in the preview"/>
  • <meta property='og:url' content='//www.example.com/URL of the article" />

Then LinkedIn will use these! Source: LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn.

Step 3 - Verifying LinkedIn Share Results

Not sure you did everything right? Take the URL of the page you are sharing (i.e., example.com, not linkedin.com/share?url=example.com), and input that URL into the following: LinkedIn Post Inspector. This will tell you everything about how your URL is being shared!

This also pulls/invalidates the current cache of your page, and then refreshes it (in case you have a stuck, cached version of your page in LinkedIn's database). Because it pulls the cache, then refreshes it, sometimes it's best to use the LinkedIn Post Inspector twice, and use the second result as the expected output.

Still not sure? Here's an online demo I built with 20+ social share services. Inspect the source code and find out for yourself how exactly the LinkedIn sharing is working.

Step 4 - Finding More Social Sharing Services and Their Share URLs

I have been maintaining a Github Repo that's been tracking social-share URL formats since 2012, check it out: Github: Social Share URLs.

Why not join in on all the social share url's?

Social Share URLs

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
11

Its best to use customize url approach. And its the easiest. Found this one. It will open a popup window and you dont need any bs authentication issues because of w_share and all.

<a href="https://www.linkedin.com/shareArticle?mini=true&url=http://chillyfacts.com/create-linkedin-share-button-on-website-webpages&title=Create LinkedIn Share button on Website Webpages&summary=chillyfacts.com&source=Chillyfacts" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;">
  <img src="http://chillyfacts.com/wp-content/uploads/2017/06/LinkedIN.gif" alt="" width="54" height="20" />
</a>

Just change the url with your own url. Here is the link http://chillyfacts.com/create-linkedin-share-button-on-website-webpages/

OXiGEN
  • 2,041
  • 25
  • 19
Kingshuk Deb
  • 1,700
  • 2
  • 26
  • 40
  • What is the role of `mywin`? I only see it in one place. – Razvan Zamfir May 08 '19 at 16:29
  • @RazvanZamfir thats the popup window name.Abbreviation of `my window` is mywin. You can add any name. – Kingshuk Deb May 20 '19 at 07:00
  • Hi, this is not working when I add my own website. But still works with yours. Any reason for that? I've tried everything.. Thanks a lot – Jessicascn Dec 05 '19 at 17:18
  • Thank you. This was far more helpful and straightforward than the official MS docs. The second option to link without the popup was exactly what I was looking for. – OXiGEN May 24 '20 at 05:35
8

The API is updated now and the previous API will be deprecated on 1st March, 2019.

To create a custom Share button for LinkedIn, you need to make POST calls now. You can read the updated documentation here for doing so.

Himanshu Aggarwal
  • 1,803
  • 2
  • 24
  • 36
5

LinkedIn has updated their api and the sharing url's no longer works. Now you can only use the url query parameter. Any other parameter is going to be removed from the url by LinkedIn.

Now you're forced to use oAuth and interact with the linkedin API to share content on behalf of a user.

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
lcjury
  • 1,158
  • 1
  • 14
  • 26
  • What are you talking about share article API still works. Can you please share a link with actual depreciation information? – Michal Apr 15 '20 at 06:11
  • 1
    @michal You can no longer find any official documentation on `https://www.linkedin.com/shareArticle` or `https://www.linkedin.com/sharing/share-offsite/` methods. [The official documentation](https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin) only talks about using oAuth as @lcjury mentioned. If you find something different you let us know. So while they do still sort of work, its only the url attribute they are accepting and who knows how long they will keep working. – Brockenstein May 01 '20 at 23:07
4

LinkedIn revised their site recently, so there are a ton of old links just redirecting to the developer support homepage. Here is an updated link to the relevant page on LinkedIn's support site (as of Feb 16, 2015): https://developer.linkedin.com/docs/share-on-linkedin

Ryan Francis
  • 635
  • 6
  • 7
3

This works for me:

https://www.linkedin.com/shareArticle?mini=true&url=articleUrl&title=YourarticleTitle&summary=YourarticleSummary&source=YourarticleSource

You can use this link by replacing it with your content. It works 100%.

petezurich
  • 9,280
  • 9
  • 43
  • 57
1

You can customize the standard Linkedin button like this, after the page load:

$(".IN-widget span:first-of-type").css({
                'border': '2px solid #DCDCDC',
                '-webkit-border-radius': '3px',
                '-moz-border-radius': '3px',
                'border-radius': '3px'
                });
Vlad
  • 109
  • 2
  • 7