admin管理员组

文章数量:1401849

I'm adding a LinkedIn share button to my site. The URL that needs to be shared includes a parameter, but LinkedIn is stripping the parameter from the URL. Any way to get around this?

I've tried using a custom share URL e.g.

;url=;title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=stackoverflow

I've also tried using their share plugin e.g.

<script src=".js" type="text/javascript">lang: en_US</script>
<script type="IN/Share" data-url="/?par=1"></script>

Neither option is working for me. The URL just defaults to the root domain.

I'm adding a LinkedIn share button to my site. The URL that needs to be shared includes a parameter, but LinkedIn is stripping the parameter from the URL. Any way to get around this?

I've tried using a custom share URL e.g.

http://www.linkedin./shareArticle?mini=true&url=https://stackoverflow./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.

I've also tried using their share plugin e.g.

<script src="https://platform.linkedin./in.js" type="text/javascript">lang: en_US</script>
<script type="IN/Share" data-url="https://website./?par=1"></script>

Neither option is working for me. The URL just defaults to the root domain.

Share Improve this question asked Feb 4, 2020 at 17:18 user715564user715564 1,6903 gold badges26 silver badges62 bronze badges 5
  • i tried accessing your url directly and it seams to be working fine. – Nicolas Commented Feb 4, 2020 at 17:21
  • What url? The one in the first example? That's just an example to show the format of that sharing option. That's not the actual url I am trying to share. – user715564 Commented Feb 4, 2020 at 17:23
  • Well if this one is working and not yours, that's probably because you are passing invalid parameters. – Nicolas Commented Feb 4, 2020 at 17:25
  • Please re-read my post. I'm having issues with parameters in the url that is being shared...not the share url parameters. – user715564 Commented Feb 4, 2020 at 17:28
  • Does this answer your question? LinkedIn Share Post URL – HoldOffHunger Commented Aug 18, 2021 at 13:14
Add a ment  | 

2 Answers 2

Reset to default 6

LinkedIn no longer supports those parameters.

2010:

https://www.linkedin./cws/share?url={url}

2016:

https://www.linkedin./shareArticle?url={url}&title={title}&summary={text}&source={provider}

2020:

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

Unfortunately, we will have to survive with only a url parameter.

Source: Official Microsoft LinkedIn Share API Docs.

But, if you want to show a preview of some site info on the share page, before the user clicks to share it, you can use og: tags...

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

Source: LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn.

And when you're all done: Test it with the LinkedIn Post Inspector.

If you have query variables in your url that you would like to pass across such as utm_campaign then you can just url encode that. For example:

example.?utm_campaign=li_share

Bees

example.?utm_campaign%3Dli_share

Where = bees %3D.

So pass that into the share url and it will keep it when shared on Linkedin:

https://www.linkedin./sharing/share-offsite/?url=https://example.?utm_campaign%3Dli_share

Just tested and it works (19th October 2023)

本文标签: javascriptLinkedIn stripping parameters from the share button urlStack Overflow