I’m wor­ried that many of you will be dis­ap­pointed with this blog post. Why? In the past, I’ve tried to tackle the really com­plex imple­men­ta­tion issues and ques­tions that you might not have seen any­where else. Some of them have been beyond hairy, fraught with gotchas and caveats and warn­ings galore.

This one? Not so much. Like it or not, if you’ve had expe­ri­ence imple­ment­ing Site­Cat­a­lyst on your own web site, imple­ment­ing on a Face­book app using Omniture’s new app mea­sure­ment solu­tion is straight­for­ward and familiar.

I will give you one notice before I go any fur­ther: The only Face­book app I’ve ever built is a sim­ple proof-of-concept to help me under­stand the solu­tion described below; your apps are likely far more com­plex, and you may have very spe­cific needs or chal­lenges that go beyond what is described below. Omni­ture Con­sult­ing is pre­pared to help you under­stand how best to gen­er­ate uplift based on your spe­cific Face­book strate­gies and app struc­tures, but hope­fully the infor­ma­tion below is enough to get you started.

The way apps work is this: You build and host a small “site” which inter­faces with Face­book via an API that has been estab­lished and a shared key that is tied to a Face­book account. Face­book serves up your app by using the API to send and receive data from the “site” (i.e, app) that you have built.

What this means is that all of the same rules apply to Face­book app imple­men­ta­tion. When you set up your app, Face­book gives you a very sim­ple, “Hello World”-esque PHP script that you can use as your first “page.” I’ve included it below and added how you might imple­ment Site­Cat­a­lyst on this page using the new Face­book app mea­sure­ment tool.

require_once 'facebook.php';
$appapikey = '93a9c39988cb7XXXXXXXXXXXXXXXX';
$appsecret = 'ec3954276b34c4b4XXXXXXXXXXXXXX';
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();


<title>Test App</title>
// Greet the currently logged-in user!
echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\" />!</p>";

// Print out at most 25 of the logged-in user's friends,
// using the friends.get API method
echo "<p>Friends:";
$friends = $facebook->api_client->friends_get();
$friends = array_slice($friends, 0, 25);
foreach ($friends as $friend) {
echo "<br>$friend";
echo "</p>";
<!-- SiteCatalyst code version: FBJS-1.0.
Copyright 1997-2009 Omniture, Inc. More info available at
http://www.omniture.com -->
<script src="s_code_fb.js"></script>
/* You may give each page an identifying name, server, and channel on
the next lines. */
s.pageName="Test App:Home"
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
s.t();//--></script><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: FBJS-1.0. -->

I would also need to have the s_code_fb.js core JavaScript file hosted on a server in my control.

All we’re pass­ing into Site­Cat­a­lyst in this exam­ple is the page name, the chan­nel (site sec­tion), and the logged-in user’s ID (not name or user­name, but a numer­i­cal ID; this is very impor­tant for pri­vacy pur­poses). How­ever, you can pop­u­late any of the vari­ables belong­ing to the Omni­ture Suite—eVars, props, prod­ucts, events, etc. It really is a full-featured solu­tion for mea­sur­ing inter­ac­tion with your Face­book apps just as you would mea­sure inter­ac­tion with your own web site! Also, note that Facebook’s API makes avail­able quite a bit of use­ful infor­ma­tion about those who inter­act with your app, mak­ing it easy to cap­ture demo­graphic and other data about your user base.

Of course, your app is likely com­prised of mul­ti­ple “pages.” You’ll be able to get pathing data as users nav­i­gate your app, and you can fire cus­tom events as they per­form what­ever actions con­sti­tute a mea­sur­able aspect of con­ver­sion or inter­ac­tion, accord­ing to your needs.

There are, actu­ally, a few things to be aware of when imple­ment­ing this solution:

  • Face­book app usage data prob­a­bly should not be inter­min­gled with usage data from your web site. After all, a “visit” to your app does not con­sti­tute a visit to your site. There­fore, I rec­om­mend using a sep­a­rate report suite for Face­book app measurement.
  • Some Omni­ture JavaScript plug-ins will work with a Face­book app imple­men­ta­tion, but not all. There are some key dif­fer­ences between FBJS (Face­book JavaScript) and con­ven­tional JavaScript that ham­per some plug-in behav­ior. For exam­ple, FBJS does not sup­port document.cookies, so plug-ins that rely on cook­ies (e.g., get­Val­Once, get­DaysSince­LastVisit, etc.) will not work. For this rea­son, Omni­ture rec­om­mends using a home-grown solu­tion, built in accor­dance with avail­able FBJS doc­u­men­ta­tion, to ensure cor­rect func­tion­al­ity, rather than rely­ing on plug-ins in your Face­book app implementation.
  • If you use first-party cook­ies in your Site­Cat­a­lyst imple­men­ta­tion on your site, you can also use them in your imple­men­ta­tion on Face­book apps by adding the s.trackingServer and s.trackingServerSecure vari­ables, set to the appro­pri­ate data col­lec­tion domains, to the s_code_fb.js file. How­ever, note that this will func­tion as third-party cook­ies to end users, because the app will be served up by Face­book and not directly by your site. Gen­er­ally speak­ing, the Omni­ture cookie is not affected by Facebook’s lim­ited cookie func­tion­al­ity. This means that (as men­tioned above) pathing data, as well as visit/visitor data, can be recorded normally.
  • App Mea­sure­ment for Face­book is only to be used for FBML appli­ca­tions. iFrame-based apps should use the stan­dard Omni­ture JavaScript code, and Flash-based apps should use Omni­ture ActionSource.

Finally, please be aware that full doc­u­men­ta­tion on the Face­book app mea­sure­ment code is avail­able within Site­Cat­a­lyst by going to Help > Help Home, then select­ing Sup­port­ing Docs > Man­u­als from the left nav­i­ga­tion menu. I’d also rec­om­mend check­ing out this blog post by my col­league, Vishal Chor­dia, from our Prod­uct Mar­ket­ing team. Happy Facebooking!