Rothana Choun
Rothana Choun

Reputation: 96

LinkedIn and google plus share successful callback

I got callback after share successfully with Facebook and Twitter. Is it possible with Linkedin and Google Plus?

Google Plus Share :

href="https://plus.google.com/share?url={URL}"

Linkedin Share :

href="http://www.linkedin.com/shareArticle?mini=true&url={articleUrl}"

Upvotes: 3

Views: 3911

Answers (2)

Vijay Singh
Vijay Singh

Reputation: 317

Try Linkedin Share widget

Set callback function on onsuccess that fires when share successfully:

<script type="IN/Share+init" data-counter="top" data-url="your share Url" data-onsuccess="tracklinkedin"></script>

On tracklinkedin function:

function tracklinkedin(reponse) {
   console.log('linkedin' + reponse);
   //do here
}

Google Plus:

<div class="g-plus" data-action="share" data-annotation="top" data-href="your url"    data-callback="trackgoogle" ></div>

function trackgoogle(reponse) {
     console.log('Google Plus' + reponse.state);
    if(reponse.state=='on')   
    {
      $SS.TrackCount('googleplus')
      //to do
    }}

Upvotes: 2

HoldOffHunger
HoldOffHunger

Reputation: 20881

Just make your own button, with its own callback, and you can ditch the LinkedIn Share Button API SDK, JS Bundle, and inShare plugins. Some of these appear to already be outdated, deprecated, and to have known issues. All you really ought to need is...

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

Then you can just make any button, using any HTML, CSS, or JavaScript that you like, and hyperlink it to allow sharing of a page. Since it's just a native button, you can control the callback however you like. And make a callback however you'd like...

HTML...

<a id="link" href="https://www.linkedin.com/sharing/share-offsite/?url={url}">Share on LinkedIn</a>

JS...

$('#link').click(function(e) { //callback stuff });

Source: Microsoft LinkedIn Share URL Documentation.

Google is probably a similar situation. If you are interested in a regularly maintained github project that keeps track of these URL formats so you don't have to, check it out! Social Share URLs

Social Share URLs Image

Upvotes: 1

Related Questions