Dec 24

In an effort to gather more data around “social media presence” in Omniture SiteCatalyst, I began investigating how to pull Twitter and Facebook data into Omniture SiteCatalyst.    After reading @VaBeachKevin’s post on importing Twitter Followers into SiteCatalyst on WebAnalyticsLand.com, I wondered if it would be possible to use the same concept to import Facebook Fans.  After a bit of searching, I found this post at stackoverflow.com, and I was off and running.  Here’s how I did it…

  1. As I mentioned, I relied on the code at WebAnalyticsLand.com to get me started.  Specifically, I grabbed the code in Kevin’s post here: Track the number of Twitter Followers in SiteCatalyst
  2. To use the PHP solution from above, I also had to download the Facebook PHP client library. To do that, go here: Facebook PHP client library. The specific files you’ll need from the library are facebook.php and config.php.
  3. You’ll need to modify config.php to contain your API Key and Secret Key from Facebook.  I set up a testing Facebook APP to get one.   Go here: http://www.facebook.com/developers/apps.php From my experience, it didn’t matter what account/app keys I used for these; the API and Secret Key are just needed to create the Facebook object in the code.  You can remove the database info from config.php.  This won’t be needed, as we don’t need to query any local DB.
  4. Upload config.php and facebook.php to the directory where your script will run.  I created a subdirectory for this.
  5. Finally, here is the PHP template I used: Get Facebook fans and Add to Omniture
  6. At the top of getFBFans.php, make sure the following lines reference the correct location of config.php and facebook.php:
    include_once ‘facebook.php’;
    include_once ‘config.php’;

  7. In the block beginning at line 14, edit the commented lines for the appropriate Omniture details and Facebook page ID. To get the Facebook page id, I found it easiest to search for the fan page, then click on the main profile photo. The URL will then show you the page/account ID. For example: http://www.facebook.com/album.php?profile=1&id=6181619439.  The id 6181619439 is what you’ll put at line 23 in getFBFans.php.
  8. The event you use in SiteCatalyst MUST be configured to numeric, rather than counter. Go into SiteCatalyst Admin settings for the respective report suite to configure this.
  9. Upload getFBFans.php to a PHP server. Any time you hit that PHP file, it will perform the FQL query to Facebook and import into Omniture using the Data Insertion API.  My suggestion is to set up a cron job to run the script hourly,  for hourly trending in SiteCatalyst. NOTE: Running this script more than once per hour will inflate fan count! It is very important that you only run the script once per hour.

EDIT: After looking at the data as its coming in, I think I will reschedule this script to run once per day. Because hourly granularity in SiteCatalyst can only be viewed for a maximum of 14 days, it’ll be much easier to see trends over large date-ranges by looking at a daily granularity.

And that’s it!  Of course, if you notice any issues with my explanation or the code in the files, please let me know so I can make corrections.  Enjoy!

2 Responses to “Tracking Facebook Fans in Omniture SiteCatalyst”

  1. [...] This post was mentioned on Twitter by Rudi Shumpert and Andy Batten, Andy Batten. Andy Batten said: @ben_rob @RRS_ATL @OmnitureCare @VaBeachKevin How I imported Facebook Fans into Omniture: http://bit.ly/70bEd9 Let me know of any issues. [...]

Leave a Reply

preload preload preload