Before committing to a social strategy it can be useful to do some analysis first. For example, it might be useful to find out if your users are on a specific platform at all. At Searchlove London last week, Mat Clayton of Mixcloud gave an awesome tip on how to find out how many of your users are logged in to Facebook.
I modified his script a bit to make use of a new Google Analytics feature that makes sure the tracking does not affect bounce rates, as it by default does. Andre Scholten wrote a post on the change and how it works.
1. Create a Facebook App
The first step is to create an empty Facebook App that we’re only going to use for this purpose, so do not bother with all the settings. The only thing you have to do is to fill in the ‘App Domain’ and the ‘Site URL’ , as marked by the arrows in the screenshot.
We will use this app to check if the user authorized it to use his Facebook data. The Facebook API returns a status code for the currently logged in user, even though they will never see any prompts or popups from Facebook itself. This gives us the possibility to silently track the number of people logged in to Facebook!
The next step is to insert the following script (with your App ID on line #4) at the bottom of your site:
This script loads the Facebook API asynchronically (so it doesn’t slow down your site) and checks if the user is authorized with your app. Since we only created a shell app that no one ever sees, the status returned will be either one of the following options: not_authorized or unknown.
not_authorized means the user is not connected with your app (which is obvious, as we never asked them to authorize), but the real value is in combination the other status: unknown. This means that the user is not logged in to Facebook at all. As a result you can measure the number of visitors that are logged in to Facebook, which I think is a pretty good indicator if they are on Facebook at all. Of course some people are logged out of Facebook, for example at work or on their phone, but overall this gives pretty solid data.
Lastly, the script calls a Google Analytics TrackEvent with the specific status code as the value. By using the updated API call it will not affect bounce rates, so you can use your normal Analytics profile.
3. Watch the data flow in
In Analytics the data becomes available under Content > Event Tracking. In this example the category is called ‘Facebook’ and the event is called ‘Status’. You can change both in the script if you like.
Finally, you should look at ‘Unique Events’ as this number only counts visitors once. After a short while we found out that 32,8% of our Dutch visitors are on Facebook, and this number seems pretty stable the more data points we gather.
I’ve tried to do something similar with both Twitter and LinkedIn, but unfortunately their APIs only return if the user is authorized or not, so no tricks there. If anyone knows how to set this up for them, please let me know!
Update 19-01-2012: Facebook changed ‘NotConnected’ to ‘not_authorized’.