简体   繁体   English

顶赞按钮未与javascript sdk,谷歌分析和顶赞代码一起显示

[英]Like button doesn't show with javascript sdk , google analytics and like code

I'm using the javascript sdk in my application, and I would like to integrate the like button. 我在我的应用程序中使用javascript sdk,并且希望集成like按钮。

Here's my code : 这是我的代码:

 // javascript sfk to connect user and get infos
<script id="facebook-jssdk" src="//connect.facebook.net/en_US/all.js"></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.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

<div onClick="_gaq.push(['_trackEvent', 'Like', 'Clicked on Facebook Like Button']);" class="fb-like" data-href="https://url/id/fr" data-width="140px" data-height="27px" data-colorscheme="light" data-layout="button_count" data-action="like" data-show-faces="false" data-send="true"></div>

Edit : My opengraph fields : 编辑:我的opengraph字段:

  • og:title, OG:标题,
  • og:description, OG:说明,
  • og:type, OG:类型,
  • og:image, OG:图像,
  • og:url, OG:URL,
  • og:site_name, OG:SITE_NAME,
  • fb:admins, FB:管理员,
  • fb:app_id FB:APP_ID

    are filled correctly on my page 正确填写在我的页面上

    and the faecbook debugging tolle https://developers.facebook.com/tools/debug/ says everything is fine Response Code 200** 并且faecbook调试tolle https://developers.facebook.com/tools/debug/表示一切都很好响应代码200 **

The result is ... nothing :D 结果是...什么都没有:D

The code is on the page, but I don't have any like button ! 代码在页面上,但是我没有任何喜欢的按钮! I try to change it by css but nothing changed 我尝试通过CSS更改它,但没有任何更改

I find an old article (2010) that says that you can't use facebook SDK and the like button code provide by facebook http://allfacebook.com/one-problem-with-facebooks-new-like-button-it-doesnt-work-with-connect-sites_b13946 我发现有一篇旧文章(2010年),说你不能使用facebook SDK,facebook提供的类似按钮代码http://allfacebook.com/one-problem-with-facebooks-new-like-button-it-犯规工作与-连接- sites_b13946

Or is it a probleme with my google analytic onClick ? 还是我的Google analytic onClick有问题?

Thanks in advance :) 提前致谢 :)

So, there a little trick inside the url to the facebook javscript SDK : You have to specified #xfbml=1 to display like or share buttons. 因此,facebook javscript SDK的网址中有一些技巧:必须指定#xfbml = 1才能显示“喜欢”或“共享”按钮。 in the javascript function the url should be : 在javascript函数中,网址应为:

js.src = "//connect.facebook.net/en_US/all.js #xfbml=1 "; js.src =“ //connect.facebook.net/zh_CN/all.js#xfbml = 1 ”;

Even if fbml and xfbml has been deprecated since june 2012. https://developers.facebook.com/docs/roadmap/completed-changes/ 即使自2012年6月起已弃用fbml和xfbml。https ://developers.facebook.com/docs/roadmap/completed-changes/

And of, course, not a single line about it on the share button documentation. 当然,在共享按钮文档中也没有一行关于它的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM