Import Facebook Page Data to Google Sheets

Import Facebook Page Data to Google Sheets

Comments:22

  1. Is there a way to bring in insight information alongside the individual posts? So, after section 4 when you bring in all of the latest Facebook posts, is it possible to have additional columns with impressions, post likes etc?

    1. Hi Michael, you can do that by creating an API URL like this:

      https://graph.facebook.com/{page ID}/posts?fields=insights.metric(post_impressions,post_reactions_like_total)&access_token={page access token}

      Substitute in your own page ID and access token, and you’ll see a list of all your page posts alongside impressions and likes. You can see a list of all available metrics here: https://developers.facebook.com/docs/graph-api/reference/v3.0/insights#availmetrics

      Note that the page posts will be identified with an ID under the field data » id. To link the IDs back to a name, you can run the request described in Part 3 above, since that contains both the post ID and the post name.

    1. Hi Alex, yes, you can import Facebook Ads data to Sheets with this method, using a very similar process. However, it’s not as convenient because FB ad data requires a user token rather than a page token, and user tokens aren’t permanent. So if you use that method, you will need to manually update your tokens every 2-3 months.
      Therefore, for FB Ad data I suggest using a tool that will refresh FB tokens automatically for you. (You can find a few if you search the G Suite Marketplace for ‘Facebook ads” or similar).

      1. Hi Ana,

        Can you please help me in setting up the API for Facebook Ads. I am not from a coding background but this tutorial actually motivated me to try this for my Facebook Ad account. I need to track my daily spends on campaign level. Thanks in Advance

    1. The regular /feed endpoint will include data for any videos you’ve posted, but if you want videos only, you can make a request to the /videos endpoint. You can add in the fields you want as described in the video endpoint documentation at https://developers.facebook.com/docs/graph-api/reference/video/.
      For example, a request to this URL

      https://graph.facebook.com/v5.0/{account}/videos?fields=title,description,embed_html,length,picture&access_token={token}

      would return the titles, descriptions, HTML, video length, and thumbnail for all your videos. There’s also a ‘content_tags’ parameter listed in the documentation, but it only returns a numeric value so I’m not sure how useful it is.

  2. First off just want to say this is a brilliant add-on!

    I’m having a go at bringing in Facebook video insights, but it’s displaying in a weird way:

    Using the exmapl;e posted above bringing in video insights, it’s displaying them very strangely, almost in multiple rows rather than columns folr each video, so it’;s mixing up the data?

    1. Thanks a lot, I appreciate that : ) As for mixing up the data, I’m not exactly sure what you’re seeing. To me it looks all right (if complicated), with each metric name followed by its count in the subsequent column. You can try changing the Report Style for a different JSON-to-Sheets algorithm, or limit the number of metrics you pull in at once so that the output doesn’t get so complex. This API wasn’t designed to be consumed in Sheets, so Facebook didn’t put much thought into producing JSON that looks clean when it’s flattened out.

  3. Hi Ana,

    Great article, thanks. Just one question. I’ve seen that Facebook requested you for some permissions that you didn’t have (manage_pages and read_insights). How it was possible to move on without this permissions?

    Thank you!

    1. Hey John, those permissions are only required if you’re developing and publishing an app for other people to use (documentation). So basically we don’t need to worry about it because we’re the only ones using our apps.

  4. Any ideas how to convert the datetime from the first column to normal date and time columns in sheets? Facebook API spits out YYY-MM-DDTHH:MM:SS+0000 (HHs in UCT). I would love to convert to local date and time, but the only hypothetical solution I’ve come up with is pretty complicated.

Leave a Reply

Your email address will not be published.