本文介绍了Facebook喜欢:href url vs.规范的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了跟踪目的,我希望在喜欢动作之后的facebook流中显示的URL与用户实际喜欢的URL略有不同。



示例:
我使用< link rel =canonicalhref =http: /example.com/test.html\"> 在我的头部,告诉Facebook本网站上的一个相似的动作是哪个网址。



进一步在网站上,我有< fb:like href =http://example.com/test.html?param=144141> with相同的URL,只是附加一个参数。



我的意图:如果有人点击类似的按钮,Facebook将他交给喜欢,以便显示如下按钮。但是当另一位用户在facebook流上看到他的动作并点击它时,他应该被重定向到。



问题是这不行,因为规范声明头部类覆盖我的< fb:like> 标签的href属性。任何人都知道如何解决这个问题,或者根本不起作用?

解决方案

你不能完全按照你的要求,但您仍然可以添加任意跟踪参数(对于分析目的尤其有用)。 Facebook 到 fb:like 元素为此目的。决定如何将各种信息填充到该参数中,然后解析 fb_ref ,只要它包含在传入的URL中。



示例



将以下元素放在HTML页面上:

 < fb:like href =http://example.com/test.htmlref =144141>< / fb:like> 

用户点击Facebook上的链接应该被引导到:

  http://example.com/test.html?fb_ref=144141&fb_source=home_multiline 

文档







for tracking purposes, I want that the URL, which appears on the facebook stream after an "like-action", is slightly different from the URL the user actually liked.

Example:I use <link rel="canonical" href="http://example.com/test.html"> in my head section to tell facebook to which URL a like-action on this website refers to.

Further down on the website I have <fb:like href="http://example.com/test.html?param=144141"> with the same URL, just with an additional parameter.

My intention: If someone clicks on the like button, facebook puts him to the "group who like http://example.com/test.html" in order to appear next the like button. But when another user sees his like-action on the facebook stream and clicks on it, he should be redirected to http://example.com/test.html?param=144141.

The problem is that this doesn't work, because the canonical declaration in the head section kind of overwrites the href attribute of my <fb:like> tag. Anyone knows how to solve this problem or does it simply not work?

解决方案

You can't do exactly what you have requested, but you can still add an arbitrary tracking parameter (especially useful for analytics purposes). Facebook recently added a ref parameter to the fb:like element for this purpose. It's up to you to decide how you want to stuff various bits of information into that single parameter and then parse fb_ref whenever it's included in an incoming URLs.

Example

Place the following element on your HTML page:

<fb:like href="http://example.com/test.html" ref="144141"></fb:like>

Users clicking the link from Facebook should be directed to:

http://example.com/test.html?fb_ref=144141&fb_source=home_multiline

Documentation

这篇关于Facebook喜欢:href url vs.规范的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 05:20