Import Facebook Page Data to Google Sheets

In this guide, we’ll walk through how to pull Facebook fan page data from the Facebook API directly into Google Sheets, using the API Connector add-on for Google Sheets. Facebook Pages serve as a business presence for many companies, so we want a way to grab some stats about what people are clicking and reading on these pages.

There are 2 ways to connect to the Facebook Pages API:

  • Preset "Connect" button (OAuth)
  • Personal access token. Please check the appendix for detailed instructions to retrieve your token.


Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Connect to the Facebook Pages API

The easiest way to get started with the Facebook Pages API is through API Connector’s built-in integration.

  1. In Sheets, open API Connector and create a new request (Extensions > API Connector > Open > Create request)
  2. Select Facebook Pages from the drop-down list of applications
  3. Under Authorization, click Connect to Facebook Pages
  4. You'll be asked which Pages to connect. Click through to connect your account.
  5. You’ll then be returned to your Google Sheet, and can verify that your Facebook Pages connection is active.

Part 2: Pull Facebook Page Data into Google Sheets

Now that we're connected, let's pull some data into Sheets.

  1. Select the /{page_id}/insights endpoint, which allows us to retrieve overview insights about the Facebook page.
  2. Under Path parameters, select your Facebook page from the dropdown menu.
  3. Populate the required parameters: metric and period. To match most of the default metrics from your FB page's Insights Overview summary tab, select the following: page_total_actions, page_views_total, page_preview_total, page_fan_adds_unique, page_impressions_unique, page_post_engagements, page_video_views, page_daily_follows_unique
  4. Optionally select a time period for the report, through either the date_preset or since/until parameters
  5. Choose a destination sheet, name your request, and hit Run. A moment later you’ll see the response data in your sheet.
  6. (Optional) Facebook sends back dates for each metric, which clutters the report. To clean this up, click the Edit fields button (next to the Run button) and filter out any unwanted columns.
  7. (Optional) Next run a request to the /{page_id}/posts endpoint to retrieve engagement stats for the posts on your page.

Part 3: Create a Custom Request

Alternatively, you can run your own custom requests instead of using API Connector’s pre-built integration, using any of the endpoints and parameters shown in the API documentation.

Get your Facebook Page ID

To make a custom request, you'll need to get your Facebook page ID, which you can get from the Pages section of your Facebook Business Manager account.

Alternatively, you can get your page ID via the API, using the /{page_name} endpoint.

Configure Request

Once you have your Facebook page ID, add your complete URL into the Request URL field, and choose Facebook Pages from the OAuth menu (or connect with a token). Here's a sample request setup:

  • ApplicationCustom
  • MethodGET
  • Request URL,message,created_time,insights.metric(post_impressions,post_reactions_like_total, post_clicks)&limit=100
  • OAuthFacebook Pages


Flatten fields

When running a custom request to Facebook's endpoints for page/post data, data is returned in an inconvenient format, with all metrics in a single list. To clean this up we can use API Connector's Flatten field to Header (under Output options) option to flatten metrics into individual columns. This setting is automatically applied to requests created through the preset integration.


The /posts endpoint (the one shown in the custom request example above) requires a custom flattening like this:

  • Flatten field to header type: custom
  • Path to header:
  • Path to value:


The /{page_id}/insights endpoint can use the preset Facebook Pages data setting:

Part 4: Handle Pagination

  1. By default Facebook limits the number of results in a single response (usually to 25 records) as described here. To get more records, you can set the limit parameter to 100.
  2. If you have more than 100 records, then you'll need to cycle through the results in batches of 100. With API Connector you can loop through automatically using pagination handling.
    • API URL: enter your request URL, including limit=100
    • Pagination type: cursor
    • Next token parameter: after
    • Next token path: paging.cursors.after
    • Run until: choose when to stop fetching data

Part 5: API Documentation

Official API documentation:

Appendix: Connect with a Facebook Access Token

This section is provided as an alternative to the method described above. Instead of authenticating through API Connector's OAuth connection manager, you will get your own token and connect with that instead.

Note that the process for getting Facebook access tokens isn't difficult, but it is quite long and convoluted as there are several kinds of tokens. Tokens are valid for different lengths of time, and Page Access Tokens are dependent on User Access Tokens. There are many different approaches to retrieve these tokens, but the following method should be the most straightforward. The good part is, you only need to do this process ONCE, as the token you get will last forever!

Step 1: Get your Facebook API User Access Token

  1. Begin by navigating to, and click My Apps.
  2. Click + New App
  3. Facebook will ask you to choose an app type. Choose Business and click Next.
  4. Next, they will ask you to enter your app details. You can call your app anything, as long as it doesn't include any terms related to Facebook's trademarks. We'll just call our app Pages for Sheets. Enter a contact email addres and click Create app.fb-page-details
  5. You'll be directed into your Developer dashboard. You don't need to do anything in this dashboard. Instead, open up the Facebook Graph API Explorer
  6. Under 'Facebook App', select the app you just created. Click Get User Access Token from the drop-down menu.
  7. A modal will appear, prompting you to login. Click Continue.
  8. Under 'permissions', you should now see 'public_profile', meaning your token provides access to public information about yourself. Click the dropdown menu and add the permissions 'pages_read_engagement' (located under Events Groups Pages) and 'read_insights' (located under 'Other').
  9. Now click Generate Access Token.
  10. You'll see a couple modals prompting you to continue and to allow your app to access your Facebook Page and App insights, just click through these until you see a notification that the linking is complete.
  11. You should now see your new access token in the Graph API Explorer. However it's a short-lived access token and only lasts for 1 hour. We can extend it by clicking the small blue icon next to it, and then clicking Open in Access Token Tool:
  12. At the bottom of this page, click Extend Access Token.
  13. This will produce a long-lived User token. Copy it to your clipboard. You can also take note of your page ID here.

Step 2: Get your Permanent Page Token

  1. Return to the Facebook Graph API Explorer. Paste the long-lived User token you just got into into the "Access Token" field.
  2. Now in the URL field, erase what's already there and type in YOUR_PAGE_ID?fields=access_token. You can get your Page ID as shown above, or get it by navigating to your Facebook page, clicking About, and scrolling down until you see 'Page ID'. Click Submit.
  3. You'll now see a new token returned. This is your permanent Page token! Finally!! That means you'll never have to go through the above steps again, so copy it down and keep it safe.
  4. You can verify that this token is permanent by copying and pasting it into the Access Token Debugger. Click Debug, and make sure you see the following:
    • an App ID. You should your app listed at the top. If this is missing, you missed clicking through some of the required modals earlier on and need to go through these steps again 🙁
    • Type = Page (not User). You'll need a page token to get access to all the page data.
    • Expires = Never. Even though it says Data Access Expires in 3 months, the permissions we've requested are explicitly exempted from this (documented here).

Step 3: Use the Access Token

To use your Facebook token, append it to the end of your requests, like this:,post_reactions_like_total,post_clicks)&access_token=YOUR_TOKEN

Since you're connecting with a token, leave OAuth set to None.

78 thoughts on “Import Facebook Page Data to Google Sheets”

  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?

    • Hi Michael, you can do that by creating an API URL like this:,message,insights.metric(post_impressions,post_reactions_like_total)&access_token=YOUR_PAGE_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.

    • 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
      For example, a request to{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.

      • So I believe it's custom_labels but for some reason this isn't working?{pageid}/videos?fields=id,title,description,custom_labels,length,is_crosspost_video,permalink_url,picture,&access_token={access token}

  2. Amazing, thank you, I'll give it a try! I've scheduled the data to run every hour but it's giving me the whole output again, instead of just anything new - is it possible to change this?

    • API Connector doesn't check the data before printing it into the sheet, so you can either use append mode and construct your URLs so that they only pull in new data (most APIs provide some mechanism of paging where you limit data pulls by date or ID), and/or you can use Google Sheet functions like UNIQUE() to dedupe on the front end.

  3. 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?

    • 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.

  4. 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!

    • 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.

  5. 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.

  6. The column "" is blank for me. Is there a way to get the name of the Facebook user that left the comment?

    • I checked the documentation and it seems that the name field should contain the name of the user who left the comment. If it's blank, that means it's not available for some reason, I suspect it's related to some privacy-related changes.

    • Not all metrics can be viewed weekly, you can see allowable periods by checking the "values for 'period'" column in the FB documentation. So in those cases, just run a query like this that returns data by day, and then you can sum it on your end to get a weekly value.

  7. Hi thanks for do this content im very apreciate and i have a feedback for you in the step 1 part 6
    Old Permission =manage_pages now is





  8. Hi,

    I like the simplicity of the tool for setting it up to get the Facebook Data, I am running into a problem, and I tried a few times today.

    Request failed: DNS error:


    • A DNS error means the server isn't responding, but I think it's very unlikely that Facebook's server has a problem. Therefore, I'd double-check that you've entered the correct hostname. Please feel free to share your sheet or send me a screenshot of your setup if you'd like me to take a look.

  9. Hi Ana, I need a paid service from you which is: a simple app that exports all my Facebook page likers to Google spreadsheet. Can you do that to me ? thanks

    • Hi there, I don't believe the Facebook API provides this data. If you check, it says "Due to privacy concerns, a User or Page can only query their own likes."
      You can still get this data from the interface by opening Facebook, navigating to your Page, clicking Settings, and then clicking the People and Other Pages tab in the left column. You may be able to find some apps that automate this process through web scraping.

  10. Hi Ana, thank you very much for this article. It s so cool your step by step.

    I was just wondering... is the free API able to pull public information from other profiles than mine? I mean number of posts and number of fans...

    Thanks for sharing! 🙂

    • Thank you for the comment, I'm glad you like the article! That's a good question. The method above does NOT let you get data from other profiles, it's only for pages of which you're an admin.

  11. Hello, Anna.

    First of all, thank you for the wonderful tutorials. I tried to do it exactly as you said on the blog. However, I got this error message and there isn't data imported to the Google Sheet. I was stuck in the Part 4. It said:

    Request failed: Server responded with an error (400) show response
    {"error":{"message":"(#100) Pages Public Content Access requires either app secret proof or an app token","type":"OAuthException","code":100,"fbtrace_id":"ANWpWogFTk6IERheBeZ4945"}}

    Could you please help me?

    • Hi Ifa, you're welcome 🙂 Sorry it didn't work for you. I just started from scratch and went through the steps in the article all the way from the top to test if anything had changed. Everything still worked for me as written, so I'm not sure what the issue is exactly. But based on the error message, I think you may have entered in the Facebook Page ID of a page you don't have access to. By Facebook Page ID, I mean the value that goes here:

      Can you please go through the process again, making sure you've selected that Facebook page during the linking process, and have entered the correct ID for that page? (you can see your page ID when logged in as admin on the About section of your FB page).

  12. Sorry, left my contact info out... trying again:

    This works perfectly, once I figured out how to pull the data into a kind of virtual table with an array, putting ID column first and impressions column second in the array.

    Now my question is, the “fields=insight.metric” call seems to pull in just 25 posts. Is there any way to extend that to match the 100 that the other query generates?

    • Hey Michael, you can add that &limit=100 parameter to any of your request URLs to get more records. Let me know if you have any issues.

    • Facebook doesn't provide this information via the API due to privacy concerns (documented here). However, you can get this data by navigating to your Facebook Page, clicking "Settings", and then clicking the "People and Other Pages" tab in the left column. That will show you a list of people who have liked your page.

  13. Dear Ana, thank you for a great tutorial!
    Is it possible to obtain information from other users' profiles in this way?
    I do research on banking activity in social media, so I need data on the number of posts and likes on bank profiles.

    • Hi Ilona, sorry, the official API only allows you to get data for pages of which you are an Admin. If you need data on posts and likes from other profiles, you would need to look into a web scraping tool instead. Hope that helps!

  14. Hi Ana,

    Thanks for this! Very Useful.

    I am trying to use the following path to extract daily data for specific metrics from my Facebook business page, starting from Jan 1 2021. Essentially, I want a new row added for each day's metrics and want this to run daily automatically. Could you please let me know what needs to be added to make this possible?,page_impressions_paid,page_impressions_organic_unique,page_impressions_paid_unique,page_post_engagements,page_daily_follows_unique&date_preset=last_year&period=day&access_token=TOKEN_NAME

    Also, is there any way to add a column for the date that the data was pulled?

    Thank you in advance!

    • Hi Amy, you can get daily metrics by changing your date preset to yesterday, like this:,page_impressions_paid,page_impressions_organic_unique,page_impressions_paid_unique,page_post_engagements,page_daily_follows_unique&date_preset=yesterday&period=day&access_token=TOKEN_NAME

      To add a column for the date the data was pulled, you can turn on the "Add timestamp" option (located under the Output options button). You can also switch to append mode there so new data gets appended to the end of your report.

      To run it automatically you can check out our (paid) scheduling feature.

  15. Hi Ana,

    I created a Facebook/Instagram token but now I want to delete it and change it completely. Could you please tell me how I can rewrite the token?

    Thank you,

    • So essentially what I want to do is to actually keep all the settings as they are for the App that I created but to just generate a new token, replacing the old one.

      Thanks again,

  16. I would like to extract the leads from the FB business account. I have tried using the form ID to get data. it return no records. but it has lead data exist.
    The other way using Adgroup id which I couldn't get from which section of FB console.

    FB API doc has api url to retrieve lead but does not have much route to explanation.

    Do you have any idea how to download lead using API? It is mostly connected to the Ad. but no way to get form id or possible route key for leads.

  17. Hi! Ana

    What might I doing wrong? I got this error message:

    1) PageInsights: Completed with errors
    - We received an error from the API server (400) - Page authentication may not match, please verify the Page selection show response
    {"error":{"message":"(#190) This method must be called with a Page Access Token","type":"OAuthException","code":190,"fbtrace_id":"AwHtUsI-QyjU4W5fM8h4vG2"}}

    I'm trying to pull my page fans, with this URL:{Page ID}/insights?metric=page_fans&period=day&since=1625097600&until=1630627200

    • Sounds like the page ID you entered in the URL is a different from the page shown underneath the OAuth dropdown. If you have access to multiple Facebook pages, please make sure you select the correct one from the dropdown menu when making your calls, since each page is only authorized to see its own data.

    • I just tested and everything still worked for me as written. We automatically update the version number for OAuth connections, but if you're using an API key you would need to update the version number in your request URL yourself. Can you please clarify what kind of error or issue you're seeing?

  18. How do I pull Facebook page insights for the previous month to only output totals for each metric? I used the formula below but it's outputting each day as separate columns instead of a total for the month. Should I use something different than "date_preset=last_month"? I'm trying to set it up so I can schedule it to run every month, but it will make it difficult to add up columns when months have different days.{page-id}/insights?metric=page_total_actions,page_views_total,page_preview_total,page_fan_adds_unique,page_impressions_unique,page_post_engagements,page_video_views,page_daily_follows_unique&date_preset=last_month&period=month

    • Yup, exactly, can you please change date_preset=last_month to date_preset=yesterday? Then it will just show you a single day's data rather than each day within the preset period.

      Another option would be to use "since" and "until" with a range of a single day. It's an extra step to set up but will let you be really precise about which day you want to pull data for. You can reference cells to pass the since/until values in dynamically so they always represent, say, the last day of the month.

  19. Hi Team. Do you know how I can pull the facebook shared link to the google sheet? (Say that it's a link post that links to my website. I need to get the website link so that merge it with my Google Analytics data). Do you have a full guide of all the metrics and fields that are available?

    • Sure, just add in the permalink_url field like this:,id,message,created_time,insights.metric(post_impressions,post_reactions_like_total,post_clicks)&limit=100

  20. Hi, I received the following error message. What am I doing wrong? 🙁 Thanks so much in advance for your help...

    1) Facebook Data for Past Year: Completed with errors
    - We received an error from (400) - Page authentication may not match, please verify the Page selection show response
    {"error":{"message":"(#100) The value must be a valid insights metric","type":"OAuthException","code":100,"fbtrace_id":"AsYLzUMjmxMewzrgx0ACO8v"}}

  21. Hey Ana,
    Awesome and very insightful tutorial.
    1) My main concern is i want data like: likes, impressions, engagements, shares, publish date, comments, link clicks, total clicks etc, basically want to make a powerbi dashboard, but when i run "post_impressions" i get aggregated value(people reached + impressions + engagements), Can you help me with this?

    2) Also when i get the output, how can i export it successfully to powerbi or another form which powerbi accepts?
    Thank you!

    • I'm not sure if you're trying to fetch data for a page overall or for a list of posts, but either way you can fetch any available metrics with a custom request. Here's the full list of available metrics, including Facebook's definitions for each one. For post_impressions it says "The number of times your Page's post entered a person's screen. Posts include statuses, photos, links, videos and more." That doesn't sound like it includes engagements, is there a reason you think it's an aggregate value?
      As for the output, I'm not familiar with what PowerBI accepts but I checked online and it seems you can pretty easily import Sheets data. The output is in a standard Sheets table, so I don't think there should be an issue, but let me know if you've come across some kind of problem.

      • Hey Ana, Thank you for your response.
        Yeah i am trying to fetch the data of every post in my page.

        " That doesn't sound like it includes engagements, is there a reason you think it's an aggregate value?'
        Yeah, i exported the analytics in excel to check whether my code is giving proper result and when i ran post_impressions i got value 22 which is sum of above mentioned metrics in the excel file.

        My aim to create a custom request where it gives the data same as the data we get when we export the analytics data from facebook.

      • I see... you may need to just test out a couple different metrics from their list and see if you get something closer to what you expected. Since you're looking for data on the post level, you'd want the metrics with the preface post. Maybe the discrepancy is related to when you pulled the data? In their docs post_impressions* is marked with an asterisk, which indicates that it's refreshed several times during the day.

  22. Hi Ana,

    I am trying to get comments, engagements, and video views for the different posts on my page but the only metrics I can seem to pull are impressions, likes, and clicks. Do you have any recommendations as to how to get these other metrics?

    • The preset integration is limited to the most commonly used metrics, but you can create a custom request that contains any of the metrics listed in their documentation. So for example, you could use a custom request URL of,id,message,created_time,insights.metric(post_impressions,post_reactions_like_total,post_clicks,post_engaged_users,post_video_complete_views_30s_unique)&limit=100 to get most of the fields you're looking for (their docs don't show any field available for fetching comment counts).

  23. Hi,
    I did exact steps with token, prepare request in graph API explorer where I got data and then copy request into mixed analytics, but I got no data.
    The error is: "request processed, no records found" which is strange because I copied request from graph api explorer.
    I try to get data from "{page-id}insights/page_impressions_by_age_gender_unique"
    Do you know maybe why it's like that? Maybe app need to be in live mode to get data about users?

    • Can you please click Edit fields > Show raw response and see if the API sent back any data? If you see it there but not in your sheet, then please also double-check that there's no JMESPath filter removing data (under Output options). Also double check that the URL syntax is correct, the fragment you shared above doesn't look quite right so feel free to share your URL here if you'd like me to take a look.

  24. Hey Ana, I'm trying to message people from our community page and we have a google spreadsheet for it, but there's thousands of people and I'm trying to find a way to separate those who have been messaged from those who haven't. Is there a way to do that?

    • Hey Jeff, sorry, our Facebook pages connector doesn't provide access to the /conversations endpoint (and I don't think it lets you filter on people who have been messaged back or not anyway). One thing that might help is exporting all your message history, which you can do via the FB interface by clicking your profile icon > Settings & Privacy > Settings > Privacy > Facebook Page information > Download profile information > View. Then select Format = JSON, select your time range, untick everything but Messages, and click Request a download.

  25. Hi, Ana. I'm using the following custom URL to try to extract all of last month's posts and their pertinent data.,message,insights.metric(post_impressions,post_reactions_by_type_total,post_clicks),permalink_url,id

    I've tried every configuration of sidebar interface options and all the URL permutations I can think of, and it always only populates my Google Sheet with the last Facebook post of the data set (from 2023/04/18 in this case). When I click on "Edit Fields" and "Show Raw Response" I see posts ranging from today back to 4/18. I just can't figure out how to get them all to show up in my sheet when executing a request.

    • Can you please check the following? 1) Make sure "flatten field to header" is set to None or uses the flatten posts setting, 2) make sure there's no JMESPath expression that could be filtering out data, 3) this might sound a bit silly, but please double check that you're checking the correct tab. Feel free to contact support if you'd like me to check your request setup.


Leave a Comment

Jump To