最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Social media share buttons - Stack Overflow

programmeradmin4浏览0评论

On stackoverflow, down the left side of my post, there is 3 social media share buttons.

Is there a way to track if the person successfully shared with it?

I'm asking, because i track users who "like", "+1" and "tweet" to share pages, but right now I'm using the social buttons provided by the pany's like facebook, gplus, twitter and they cause my site to load slow. And it also causes a problem if the user wants to re-share a page sometime down the road, because facebook already marks it as liked, and I'd prefer a way to share pages.

I've tried a few things with my current javascript knowledge and couldn't figure it out.

On stackoverflow, down the left side of my post, there is 3 social media share buttons.

Is there a way to track if the person successfully shared with it?

I'm asking, because i track users who "like", "+1" and "tweet" to share pages, but right now I'm using the social buttons provided by the pany's like facebook, gplus, twitter and they cause my site to load slow. And it also causes a problem if the user wants to re-share a page sometime down the road, because facebook already marks it as liked, and I'd prefer a way to share pages.

I've tried a few things with my current javascript knowledge and couldn't figure it out.

Share Improve this question asked Feb 15, 2012 at 0:03 tuurbotuurbo 3615 silver badges14 bronze badges 1
  • 1 have you considered something like AddThis? addthis. – Timmy O'Mahony Commented Feb 15, 2012 at 0:10
Add a ment  | 

2 Answers 2

Reset to default 6

Do the following subscriptions

  • Facebook: subscribe to the edge.create event (http://developers.facebook./docs/reference/javascript/FB.Event.subscribe/)

  • Twitter: put a callback on the onTweet parameter (https://dev.twitter./docs/anywhere/wele#tweetbox)

  • Google+: put a callback on the callback parameter (https://developers.google./+/plugins/+1button/)

Then in your callback functions, just AJAX whatever you want back to your server for it to store. :)

Happy Coding!

Put this in Header

<!-- For Facebook -->
<meta property="og:url" content="https://you-domain." />
<meta property="og:type" content="website" />
<meta property="og:title" content="Site Title" />
<meta property="og:description" content="Site Description" />
<meta property="og:image" content="Image you want to set for posts" />
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>
(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook/en_US/sdk.js#xfbml=1" fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));
</script>
<!-- facebook Script End -->


Here are the Series of Button (Facebook, Twitter, Google+, Pinterest, LinkedIn ) put where you want to show share buttons, then Design them from CSS


<!-- For Facebook -->
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook./sharer/sharer.php?u=URL_you_want_to_Share">Facebook</a
<!-- For Twitter -->
<a data-size="large" href="https://twitter./intent/tweet?text=URL_you_want_to_Share">Twitter</a>
<!-- For Google+ -->
<a href="https://plus.google./share?url=<URL_you_want_to_Share" onclick="javascript:window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">Google+</a>
<!-- For Pinterest -->
<a  href="https://www.pinterest./pin/create/button/?url=URL_you_want_to_Share" data-pin-custom="true">Pinterest</a>
<!-- For LinkedIn -->
<script src="//platform.linkedin./in.js" type="text/javascript"> lang: en_US</script><script type="IN/Share" data-url="URL_you_want_to_Share"></script>
发布评论

评论列表(0)

  1. 暂无评论