I'm getting lots of querystrings added to urls on my site, all of the form ?fb_xd_fragment

According to the FB.init docs at http://developers.facebook.com/docs/reference/javascript/FB.init/ they've added the ability to have a custom channel url which is meant to solve 3 specific issues:

1. When auto playing audio/video is involved, the user may hear two streams of audio because the page has been loaded a second time in the background for cross domain communication.
2. If you have frame busting code, then you would see a blank page.
3. This will prevent inclusion of extra hits in your server-side logs.

I'm seeing those hits, and would prefer not to. It would be easy enough to add the following to FB.init:

 <div id="fb-root"></div>
 <script src="http://connect.facebook.net/en_US/all.js"></script>
 <script>
   FB.init({
     appId  : 'YOUR APP ID',
     channelUrl  : 'http://example.com/channel.html'  // custom channel
   });
 </script>

The contents of the channel.html file should be this single line:

According to the FB docs, not adding the channelUrl parameter means you should remove the following from your logs to ensure proper counts:

1. Matches against user-agent: "facebookexternalhit/*"
2. Pageviews containing "fb_xd_bust" or "fb_xd_fragment"
3. Track clicks from FB-hosted iframes separately from referrers (http://www.facebook.com/plugins/ http://www.facebook.com/plugins/like.php

Adding a channelUrl to fb_social would be pretty easy - but I wanted to check the maintainer thinks this is a good idea before I submit a patch?

CommentFileSizeAuthor
#4 custom-channel-url-1177776-4.patch1.89 KBburningdog

Comments

ferdi’s picture

Sounds good. If you submit a patch, that would be great. Do you have any idea how we would cache the channel page ?

thanks!

burningdog’s picture

I'm not sure how we'd cache the channel page, but I'll look into it.

ferdi’s picture

This seems relevant ? http://drupal.org/node/909910

burningdog’s picture

StatusFileSize
new1.89 KB

Thanks - I've already read that. The comment at #14 on that thread is actually the fix that I'm proposing :) So, on with the patch, which is attached.

I've added 2 headers to the custom channel url, which is now available at www.example.com/fb_social/channel

header("Cache-Control: public, s-maxage=31536000, max-age=31536000");
header("Expires: Sun, 1 Oct 2079 00:00:00 GMT");

The numbers for s-maxage and max-age are the number of seconds in one year, and the Expires date is when I turn 100 (!).

burningdog’s picture

Status: Active » Needs review

Changed status.

burningdog’s picture

*nudge*

ferdi’s picture

ferdi’s picture

Status: Needs review » Closed (fixed)
burningdog’s picture

w00t! Thanks, ferdi :)