简体   繁体   English

如何通过“ FB共享”对话框进行点击率跟踪?

[英]How do you do clickthrough tracking via the FB Share Dialog?

According to Facebook's documentation for the Share Dialog , you can use Javascript to trigger open a share dialog so that the user can share whatever URL you pass in: 根据Facebook的“ 共享对话框”文档,您可以使用Javascript触发打开共享对话框,以便用户可以共享您传入的任何URL:

FB.ui({
  method: 'share',
  href: 'https://developers.facebook.com/docs?myTrackingParam=topShareButton',
}, function(response){});

However, if you want to do any referral tracking by appending a query string to the href property gets stripped, since the FB uses the og:url meta tag when it crawls the URL. 但是,如果要通过将查询字符串附加到href属性来进行任何引用跟踪,则会被剥离,因为FB在抓取URL时会使用og:url元标记。 I use the query params to track which share buttons are causing the most traffic. 我使用查询参数来跟踪哪些共享按钮导致最多的流量。 So my question: how can you do clickthrough tracking via the FB Share Dialog? 所以我的问题是:如何通过FB共享对话框进行点击率跟踪? Is there a way to set some query string value in the URL when sharing? 共享时,是否可以在URL中设置一些查询字符串值?

After some experimentation and piecing together separate FB docs, you can indeed set whatever value that gets passed back in the fb_ref query param . 经过一些试验并将不同的FB文档拼凑在一起之后,您实际上可以设置在fb_ref查询参数中传回的任何值。 However, this requires us to turn the share into an Open Graph call. 但是,这需要我们将共享转换为Open Graph调用。

So instead of using the share method, we could use the share_open_graph method. 因此,可以不使用share方法,而可以使用share_open_graph方法。 Thus, we can set the action_properties , which would include the ref property: 因此,我们可以设置action_properties ,其中将包括ref属性:

FB.ui({
  method: 'share_open_graph',
  action_type: 'og.shares',
  action_properties: JSON.stringify({
      object:'https://developers.facebook.com/docs',
      ref: 'topShareButton'
  })
}, function(response){});

Thus, the link that is shown on the Newsfeed/Timeline will be https://developers.facebook.com/docs?fb_ref=topShareButton . 因此,Newsfeed / Timeline上显示的链接将为https://developers.facebook.com/docs?fb_ref=topShareButton And now you can do whatever tracking your heart desires! 现在,您可以做任何追踪您内心渴望的事情!

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

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