facebook like: href url vs. canonical url
Asked Answered
A

1

15

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?

Alary answered 30/6, 2010 at 13:2 Comment(0)
C
25

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

Carlson answered 30/7, 2010 at 22:44 Comment(4)
Awesome. That's enough for my purposes. Thank you!Alary
is there a way to do this if i am using HTML5 instead XFBML?Michealmicheil
@MartinSchaer, you would probably add the data-ref attribute to your div, a bit like <div class="fb-like" data-ref="144141"></div>.Carlson
@Carlson pls, see my answer...I have the same problem #16060418Ita

© 2022 - 2024 — McMap. All rights reserved.