开发者

Automate the export of Facebook Insights data

I'm looking for a way of programmatically exporting Facebook insights data for开发者_JAVA技巧 my pages, in a way that I can automate it. Specifically, I'd like to create a scheduled task that runs daily, and that can save a CSV or Excel file of a page's insights data using a Facebook API. I would then have an ETL job that puts that data into a database.

I checked out the oData service for Excel, which appears to be broken. Does anyone know of a way to programmatically automate the export of insights data for Facebook pages?


It's possible and not too complicated once you know how to access the insights.

Here is how I proceed:

  • Login the user with the offline_access and read_insights. read_insights allows me to access the insights for all the pages and applications the user is admin of. offline_access gives me a permanent token that I can use to update the insights without having to wait for the user to login.
  • Retrieve the list of pages and applications the user is admin of, and store those in database.
  • When I want to get the insights for a page or application, I don't query FQL, I query the Graph API: First I calculate how many queries to graph.facebook.com/[object_id]/insights are necessary, according to the date range chosen. Then I generate a query to use with the Batch API (http://developers.facebook.com/docs/reference/api/batch/). That allows me to get all the data for all the available insights, for all the days in the date range, in only one query.
  • I parse the rather huge json object obtained (which weight a few Mb, be aware of that) and store everything in database.
  • Now that you have all the insights parsed and stored in database, you're just a few SQL queries away from manipulating the data the way you want, like displaying charts, or exporting in CSV or Excel format.

I have the code already made (and published as a temporarily free tool on www.social-insights.net), so exporting to excel would be quite fast and easy.

Let me know if I can help you with that. It can be done before the week-end.


You would need to write something that uses the Insights part of the Facebook Graph API. I haven't seen something already written for this.


Check out http://megalytic.com. This is a service that exports FB Insights (along with Google Analytics, Twitter, and some others) to Excel.


A new tool is available: the Analytics Edge add-ins now have a Facebook connector that makes downloads a snap. http://www.analyticsedge.com/facebook-connector/


There are a number of ways that you could do this. I would suggest your choice depends on two factors:

  1. What is your level of coding skill?
  2. How much data are you looking to move?

I can't answer 1 for you, but in your case you aren't moving that much data (in relative terms). I will still share three options of many.

HARD CODE IT

This would require a script that accesses Facebook's GraphAPI AND a computer/server to process that request automatically. I primarily use AWS and would suggest that you could launch an EC2 and have it scheduled to launch your script at X times. I haven't used AWS Pipeline, but I do know that it is designed in a way that you can have it run a script automatically as well... supposedly with a little less server know-how

USE THIRD PARTY ADD-ON

There are a lot of people who have similar data needs. It has led to a number of easy-to-use tools. I use Supermetrics Free to run occasional audits and make sure that our tools are running properly. Supermetrics is fast and has a really easy interface to access Facebooks API's and several others. I believe that you can also schedule refreshes and updates with it.

USE THIRD PARTY FULL-SERVICE ETL There are also several services or freelancers that can set this up for you at little to no work on your own. Depending on where you want the data. Stitch is a service I have worked with on FB-ads. There might be better services, but it has fulfilled our needs for now.

MY SUGGESTION

You would probably be best served by using a third-party add-on like Supermetrics. It's fast and easy to use. The other methods might be more worth looking into if you had a lot more data to move, or needed it to be refreshed more often than daily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜