We’ve noticed some odd things happening to some of our stats, and it’s been brought to our attention that some of you, our customers, are experiencing similar issues. The problem pertains to pages with Facebook’s “Like” button or any of their other social plugins.
Quietly duplicating requests.
Under certain circumstances, a page with a Like button can register one extra pageview for every button you have on the page. This is undesirable, because if you run a site with, say, ten like buttons on the homepage, you’ll see eleven pageviews for each and every time someone actually views the page, not one. Obviously this is going to completely throw off all your tracked stats and analytics. Not good.
It turns out this is a quirk of Facebook’s methods. For security reasons, AJAX requests typically aren’t allowed to be sent across domains (so, for example, a facebook plugin running on yourdomain.com wouldn’t be able to send an AJAX request to facebook.com). Most sensible browsers now implement a feature where a specific header (Access-Control-Allow-Origin) can be set to allow this behaviour. With one exception. Internet Explorer, being Internet Explorer, shuns all compatible web standards, so facebook have had to make a workaround. And for reasons we can’t quite fathom, they’ve decided to do that by loading your whole page again in an invisible iframe.
How this may have been affecting you.
This has a negative impact both server- and client-side. Not all sites have the tens of thousands of servers facebook has, and this method will multiply load levels by however many Like buttons you have on the page. And because of the way it’s implemented, it can slow the client-side browser down by a massive amount too. And for those of you who have auto-playing audio or video on your pages, you may have noticed you can’t put a like button on the page, because you sometimes end up heading a second audio stream coming apparently from nowhere. That’s all caused by this Facebook’s issue.
What can you do about this?
Firstly, we’ll be rolling out a new version of our tracker this week which won’t track these fake hits from Facebook. So you won’t get crazily distorted stats. But there are a couple of other things you can do to improve the situation further. Firstly, if you are using any other analytics services that allow you to filter out certain URLs, tell them to ignore any hits with the parameters “fb_xd_bust” or “fb_xd_fragment” in the URL. For example in Google Analytics you can set a custom filter to exclude request URIs matching the pattern “fb_xd_bust|fb_xd_fragment”.
We’d also recommend you take a look at this page on Facebook’s developer site. They don’t draw much attention to it, but the “Custom Channel URL” section is extremely important to anyone who doesn’t want their stats to be completely thrown off by Facebook’s somewhat strange methods.
To sum up.
- Facebook use some strange method for their cross-domain ajax, which distorts all your stats and puts extra load on your servers, and they could do with drawing more attention to it.
- We’re rolling out a new tracker that takes care of the fake hits on our end so your stats don’t get broken.
- Check out ways to work around this so you don’t end up putting extra strain on your server, and ways to stop these fake hits showing up in your other analytics services.