none
accessing data from facebook insights new service RRS feed

  • Question

  • I see that a lot of online websites can access facebook insights new service and generate data of it ...

    how to get data from facebook insights using microsoft software..

    power query

    power bi

    Monday, June 1, 2015 9:57 AM

Answers

  • The latest Power Query Add-in, the Power BI designer (and soon Excel 2016 preview) support Facebook read_insights permission which gives users access to their Page insights: https://developers.facebook.com/docs/platforminsights/page

    You should be able to type your page ID or page name when you connect to Facebook from Power Query->From Other Sources-> From Facebook, and get the relevant insights data by manipulating the facebook URL part in Facebook.Graph("...").

    In my example, I used this Facebook page https://www.facebook.com/ZiviKivi to read insights. The page name is "ZiviKivi". I typed "ZiviKivi" in the following dialog:

    Next step is to manipulate the facebook URL in Power Query formula bar (to show the formula bar go to the View tab in the Query Editor and check the Formula Bar).

    Add "/insights" to the URL, as shown in this screenshot:

    This is how the Query expression will look like: 

    let
        Source = Facebook.Graph("https://graph.facebook.com/v2.2/ZiviKivi/insights"),
    in
        Source

    Now you are ready to go and extract insights from your page.

    Let me know if you have further questions

    Gil






    • Proposed as answer by Gil RavivMVP Monday, June 1, 2015 1:29 PM
    • Edited by Gil RavivMVP Monday, June 1, 2015 4:50 PM
    • Marked as answer by radissoufan Tuesday, June 2, 2015 12:29 PM
    Monday, June 1, 2015 1:25 PM

All replies

  • The latest Power Query Add-in, the Power BI designer (and soon Excel 2016 preview) support Facebook read_insights permission which gives users access to their Page insights: https://developers.facebook.com/docs/platforminsights/page

    You should be able to type your page ID or page name when you connect to Facebook from Power Query->From Other Sources-> From Facebook, and get the relevant insights data by manipulating the facebook URL part in Facebook.Graph("...").

    In my example, I used this Facebook page https://www.facebook.com/ZiviKivi to read insights. The page name is "ZiviKivi". I typed "ZiviKivi" in the following dialog:

    Next step is to manipulate the facebook URL in Power Query formula bar (to show the formula bar go to the View tab in the Query Editor and check the Formula Bar).

    Add "/insights" to the URL, as shown in this screenshot:

    This is how the Query expression will look like: 

    let
        Source = Facebook.Graph("https://graph.facebook.com/v2.2/ZiviKivi/insights"),
    in
        Source

    Now you are ready to go and extract insights from your page.

    Let me know if you have further questions

    Gil






    • Proposed as answer by Gil RavivMVP Monday, June 1, 2015 1:29 PM
    • Edited by Gil RavivMVP Monday, June 1, 2015 4:50 PM
    • Marked as answer by radissoufan Tuesday, June 2, 2015 12:29 PM
    Monday, June 1, 2015 1:25 PM
  • Thank you ..you guys are great

    Tuesday, June 2, 2015 12:29 PM
  • There is a Facebook bug that prevents using Graph API to pull Insights data from pages.

    Once this gets fixed we will update you.



    Thursday, July 2, 2015 12:10 PM
  • Hi Gil,

    I will post the same question from Yammer to the broader TechNet "audience":

    1) Is there a list of Facebook API "fields" that PQ *CAN ACCESS" or even a list of what's NOT supported?

    2) This is directly from a customer ask - it's impossible to test as their Facebook page is relatively "new" but how should they set up their pages going forward to "setup for this type of BI metrics" ?

    “Am I as the page owner, able to extract the data about the people who have liked my page, including email, Facebook user name, demographics, psychographic.  

     Can we pull data about the people who have liked the page's and individual posts? 

     Looking to analyze the people WHO have liked a 'Page' and then analyzing WHO are the people engaging with each post. 

    As opposed to content analytics, "25 likes" we want to analyze who are those 25 people are who have liked the post”  

    Thanks,

    Scott

    • Edited by AAC-Scott Thursday, August 6, 2015 7:03 PM
    Thursday, August 6, 2015 7:03 PM
  • Hi Gil,

    I don't know if you are back but "any ideas" on how to once again use Facebook?

    Thanks,

    Scott

    Monday, August 31, 2015 2:14 AM
  • Hi Scott, You can use Power Query to extract from Facebook anything which is supported in their Graph API version 2.2. The problem is that they still have a bug in retrieving page Insights. What you can still get is the number of likes/shares/comment for all the posts of a page, but without the user demographics which are available through Insights. You can also extract comments to perform analysis on the messages, and can get part of the user names who commented, shared or liked the posts, but without the gender, age or any demographics. I can share an example, if this scenario is relevant.
    Monday, August 31, 2015 6:31 PM
  • Hi Gil,

    Thank you VERY much for the reply ... YES, please share anything you can !

    Scott

    Monday, August 31, 2015 6:44 PM
  • Hi Scott,

    This example extract the posts, and the number of likes/shares/comments per post.

    You can copy the query expression below into a blank query in your workbook (In Excel 2016, Get & Transform group --> New Query --> From Other Sources --> Blank Query). Then open the Advanced Editor and paste the expression.

    I marked in bold two elements that you can adjust to analyze your page.

    The first element is the page name (As it is used by facebook). In my case I used Microsoft Excel page, which is called microsoftexcel. The second element is how many posts you would like to extract. Check out the line that starts with #"Kept First Rows". Currently I used the number 10, which means that we extract only the last 10 posts. You should change this number to the number of posts you would like to extract. For debugging purposes, it's best to keep a small number till you finish the reports, because the refresh time is very slow.

    let
        Source = Facebook.Graph("https://graph.facebook.com/v2.2/microsoftexcel"),
        connections1 = Source[connections],
        posts = connections1[feed],
        #"Kept First Rows" = Table.FirstN(posts,10),
        #"Removed Other Columns" = Table.SelectColumns(#"Kept First Rows",{"from","message", "name", "description", "type", "created_time", "likes", "shares", "comments", "id"}),
        #"Aggregated likes" = Table.AggregateTableColumn(#"Removed Other Columns", "likes", {{"id", List.Count, "Count of likes.id"}}),
        #"Expanded shares" = Table.ExpandRecordColumn(#"Aggregated likes", "shares", {"count"}, {"shares.count"}),
        #"Aggregated comments" = Table.AggregateTableColumn(#"Expanded shares", "comments", {{"id", List.Count, "Count of comments.id"}}),
        #"Renamed Columns" = Table.RenameColumns(#"Aggregated comments",{{"Count of likes.id", "likes"}, {"shares.count", "shares"}, {"Count of comments.id", "comments"}}),
        #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"created_time", type datetimezone}, {"shares", Int64.Type}, {"comments", Int64.Type}, {"likes", Int64.Type}}),
        #"Expanded from" = Table.ExpandRecordColumn(#"Changed Type", "from", {"name"}, {"from.name"}),
        #"Renamed Columns1" = Table.RenameColumns(#"Expanded from",{{"from.name", "from"}})
    in
        #"Renamed Columns1"

    I can also share more advanced scenarios, like getting the user names, but it is not very practical, unless you have another list of users that you would like to compare/join with facebook data.

    Monday, August 31, 2015 8:00 PM
  • Hi Scott

    For the first question, any field or edge that requires one of the following permissions, we can access:

    user_likes,

    user_friends,

    read_insights,

    email,

    user_status,

    public_profile,

    user_about_me,

    user_posts

    Unfortunately, that's as much as Facebook would allow us to access.

    For extracting information about specific users, Facebook disabled that. You can only get information about a user if they have also approve our App (PowerQuery or PowerBI) to get access to their data.

    In terms of who liked posts and analysis on those, I'm afraid that's not possible today. :(


    Thanks, Hadeel

    Monday, August 31, 2015 8:13 PM
  • Thank you both ... I will turn this over tom Facebook Consultant guru and see what he might ask or be able to do !

    In the "broad scheme of things", Microsoft and Facebook are BOTH "800# Gorillas" in this space ... and, I would guess from reading a LOT of articles and blogposts that there may be relationships at multiple levels.

    Just wondering IF "you think" that the "bug(s)" will be short term or longer term?

    I ask, ONLY because "a Facebook connector" is STILL listed prominently - last I checked - on both Excel 2016 and Power BI 2.0 !

    Scott

    Monday, August 31, 2015 8:34 PM
  • Finally the latest Excel bits which are available on Office 365 build 16.0.6568.2036 has a fix that supports Facebook Insights and prevents the refresh failures.

    Please follow my blog datachant.com for the relevant tutorial. It's coming soon.

    Monday, March 7, 2016 4:53 PM