I want users to be able to use the facebook send button to send friends a link to a page on my site. The page itself is the generic sign-up page, but if there is a “referral_code” query string parameter it indicates who referred the user. In that sense, the URL is unique, even though the page is not. So, I do the following on a page called /referrals (with the jssdk already loaded):
<span class="fb-send" data-href="http://my.domain.com/sign_up?referral_code=unique-to-each-user"></span>
The send button opens the dialog correctly, but it is including a lame image and text in the message using whatever selection heuristic facebook engineers have built.
I read a little further in the docs and find I can use og:image on the /sign_up page to specify the image to use (as long as the width/height ration is < 3!).
So, on http://my.domain.com/sign_up I add the requisite og tags.
The pickle: if you use any og tags then you must also include og:url, and it seems that og:url takes precedence.
My question, then, is, am I right that og:url takes precedence over data-href? And if so, is there some other technique I can use that allows me to include the og tags on the target page (static) while still specifying the exact URL (dynamic) to send/like?
You are right that Facebook will take the value of the OG:url over what is provided as data-href.
However the ref attribute should do what you want. From the send button docs:
So if you provide the ref attribute in your send button code the referral id will be added to the incoming url:
The above code would produce this as the URL in the stream story:
When clicked through to your site you could grab the value of fb_ref and determine which user provided the referral.