Connect Facebook Page Insights API to Google Sheets

Connecting to the Facebook Post Insights API to Google Sheets via SyncWith

In this reference we’ll look at how to setup a Facebook Page Insights API connection.
We’ll use SyncWith to get your Facebook Page Data into Google Sheets. Please see our Facebook Ads Guide to see a full listing of all our facebook connections, templates, tutorial and specific facebook ads advertising use cases.
In SyncWith if you search for facebook you’ll get a few results, this guide deals with moving Facebook Page data into Google Sheets. You can check out our guides for Instagram Post Insights and Facebook Post Insights.
As a reference this connector utilizes the API graph, specifically the published_posts endpoint https://graph.facebook.com/v13.0/{FACEBOOK-PAGE-ID}/insightsv, if you’re curious about calling the api directly we have published a comprehensive Facebook Graph API Guide.
notion image

Don’t Have SyncWith?

  • SyncWith is a Google Sheets Add On
  • SyncWith allows you to move data from any API into Google Sheets
  • Learn more about why Marketers love SyncWith
  • Check out our Google Workspace Listing and see why we’re the highest rated API add on with over 100,000 installs. Install today and get your data into Sheets in minutes.

Choose a Reporting Time Frame

You can choose from a wide range of default reporting time frames as well as dynamic ones. Some marketers and agencies might report on the last 21 weeks of data. You may or may not want to see the current day in the reporting period.
All are possible with the date range picker. Popular options include:
  • Last 30 days
  • Last 90 days
  • Last Month
  • Month to Date
notion image
Facebooks Page Insight API has a maximum time range of 93 days, if you exceed it you’ll get a 400: Bad Request.
If you want to gather periods larger than 93 days it’s possible but you would need multiple connections to do it.
One option if you want historical as well as the last 90 days of metrics is to set the Update mode to Update or add rows as needed then you can run multiple queries with the same connector and it will add rows that it hasn’t seen before and update one’s with dates it has (if the metrics have changed). To do this just keep refreshing the connection with different time periods until you’re current and then set it to pull the last 7 days every day and you’re set.
Error you’ll get if you request too long of a time period
{ "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_subcode": 1504016, "is_transient": false, "error_user_title": "Time range too long", "error_user_msg": "There cannot be more than 93 days (8035200 s) between since and from.", "fbtrace_id": "AW4UgMt_jlTuIFy_RWXdZWI" } }

Choosing Your Dimensions

There are no dimensions available for the Page insights API except Date which is automatically included. If you feel we’re missing anything please contact support and we’ll prioritize the updating of our Facebook Page connector.

Choosing Your Metrics

Now what you want to know about your page. Date is included as a dimension so we pick our metrics to track over time. For example you may want to focus on Page Fans to understand the growth rate of your fans over time. You could just look at Fan Adds and chart that alongside Page Post E ngagements to see if posts are driving increased fans or track Viral Reach and compare that to Fan Adds to see if your content being shared is correlated with you getting more Fans.
notion image
Here is a summary of the more popular metrics available
Popular Page Insight Metrics
Metric
Description
Page Post Engagements
The number of times people have engaged with your posts through reactions, comments, shares and more.
Engaged Page Users
Total number of people who clicked anywhere on the post (comment, share, like, react, play, view photo, etc.)
Unique Page Website Clicks
Total number of people who clicked the goto website button.
Page Views Total
The number of times a Page has been viewed by logged-in and logged-out people.
Page Video Views
The number of times your Page's videos played for at least 3 seconds, or for nearly their total length if they're shorter than 3 seconds. During a single instance of a video playing, we'll exclude any time spent replaying the video.
Non-Viral Impressions
Total Impressions less Viral Impressions. See Viral Impressions
Unique Page Consuptions
The number of people who clicked on any of your content.
Viral Reach
Total number of people who had posts, stories, check-ins or social notifications of people interacting with your Page enter their screen on a given date to because of a social interaction for example a friend who engaged with the post (like, share, react) causing it to be seen from someone who does not follow your page.
Organic Reach
Total number of non-paid unique people who had any content about or from your Page enter their screen. This could include posts, stories, ad, check-ins, social notifications of people interacting with your Page on the given date (Viral Reach + Organic Reach NOT Paid Reach). Reach uses the page_impressions_unique metric in the graph API. Facebook does stipulate that sometimes the total reach will not always equal viral + organic. Utilizes page_impressions_organic_unique from the FB API.
Impressions
Total number of times posts, stories, check-ins, ads or social notifications of people interacting with your Page on a given date entered a screen, it is non-unique including Viral and Organic Impressions and utilizes the page_impressions metric from the API.
Paid Reach
Total number of unique people who had any post or story content from your page or about your Page on the given date viewable on their screen through paid promotion
Viral Impressions
Total number of times posts, stories, check-ins or social notifications of people interacting with your Page on a given date entered a screen causing it to be seen from someone who does not follow your page. For example a user’s friend likes or follows your Page, engages with the post, shares a photo of your Page and checks into your Page.
Reach
Total number of non-paid unique people who had any content about or from your Page enter their screen. This could include posts, stories, ads, check-ins, social notifications of people interacting with your Page on the given date . Reach uses page_impressions_unique from the FB API.
Page Consumptions
The number of times people clicked on any of your content.
Page Fan Adds
Number of new people who have like your page on a given day
Page Fans
Number of people who have liked your page at any given point in time
Logged-in Page Views
The number of times a Page has been viewed by people logged in to Facebook.
Page Total Actions
Daily total post reactions of a page.
Non-Viral Reach
Total Reach less Viral Reach.
Unique Page Get Directions Clicks
Total number of people who clicked the Get Directions button.
Unique Page Call Phone Clicks
Total number of people who clicked the Call Now button.
Non-Viral Reach
Total number of people who had your post viewable on their screen. This does not include viral reach. See Viral Reach
Organic Impressions
Total number of times posts, stories, check-ins or social notifications of people interacting with your Page on a given date was shown on a person's screen through unpaid distribution.
Paid Impressions
Total number of times any post or story content from your page was shown on someone’s screen through paid promotion
 

Sorting By Specific Metrics or Dimensions

Results are sorted by Date in ascending order.

Setting the Update Mode

SyncWith supports 3 update modes:
  1. Replace contents of sheet
  1. Append rows to end of sheet
  1. Update or add rows as needed
The first two options are simple in nature, the last option to update or add rows as needed is more advanced.
notion image

Replace Contents of Sheet

PREFERRED MODE for almost all Facebook Page Insights use cases
Every time you refresh or SyncWith refreshes based on your predefined schedule, all the cells will be deleted and the new data will be inserted.
  • Any computational rows that you’ve added will not get deleted as long as they are outside of the range being updated. If you’ve inserted a computational row in between other data rows it will get over written
  • Formatting you apply will stay in tact, eg if you specify a percentage, number, date that formatting for the column will persist
  • This mode is ideal for when you don’t want to collect or store previous data. For example you just want the last 30 days of data.

Append Rows to End of Sheet

NOT COMMONLY USED OR RECOMMENDED for Facebook Page Insights use cases
Every time you refresh or SyncWith refreshes based on your predefined schedule SyncWith will append the new rows to the last line with data
  • The entire sheet will not be re-sorted based on any sort you have but the appended data will be sorted and appended according to the sort you specified.
  • It will NOT prevent duplicate rows from being created
  • It will NOT update existing rows
  • If you want to only append new rows or properly update existing rows then you need to use Update or Add Rows as Needed
  • This is not a popular updating mode for Facebook users

Update or Add Rows as Needed

USED for Facebook Page Insights use cases where you need to collect historical data
  • This mode uses the date as a key to determine if a row is unique.
  • If the row is unique (we don’t have data from that date yet) then it will add a new row
  • If the row is not unique it will update the metrics if they’ve changed, eg you pulled a partial day or FB updated data from a recent date and the most recent pull will update the metrics for the days where the data changed.
This update mode is a great option if you want to collect historical page data, by doing many successful 90 day period pulls of your data across oldder date ranges you can collect all your historical data, then change the connector to just get the last 7 days data on a daily basis.

Scheduling Your Facebook Page Insight Data to Google Sheets

Manual Refresh

Manual Refresh Is the default scheduling for a connection. Data will not be updated until you actively refresh it. In order to refresh the data you must either:
  • Refresh your data from in the SyncWith addon side bar via the refresh button - all connections can be manually refreshed
notion image
  • Refresh via the Add-on menu, allowing you to refresh all connections setup, or all connection(s) pushing data to the current active sheet
notion image
  • Refresh via the check box (located in the header above the data table)
notion image

Scheduled Refreshes

There are 3 options for scheduled refreshes:
  • Automatically refresh daily will refresh the data every day at the same time. The time is set based on when the connection was last updated. If you wish to set the refresh to happen at a specific time you would need to open the connection and save it at that time.
  • Automatically refresh hourly will refresh the data every hourly
  • Automatically refresh every 5 minutes will refresh the data every 5 minutes. This is not typically used for facebook data and especially not for daily facebook page stats. A maximum of 100 connections can use 5 minute refresh.

Sample Connections

Viral vs Non Viral Impressions

This is a simple analysis to see if we’re getting more impressions from our fans or from our fans sharing and interacting with our content and how that’s trending over time. This particular graph would benefit from a moving average being applied.
Here’s what the data coming back will look like:
notion image
notion image
If we graph this data it can look pretty spikey, here we’re using a stacked stepped area chart. You can sorta see that the viral impressions are greater (more area) than the non-viral impressions but a moving average does really help, so we add two helper columsns to get that data, in this case we’re using a 14 day simple moving average.
The second graphs shows the 14DMA and it makes the data a lot easier to interpret because it smooths out the noise. Please read our tutorial on calculating moving averages with array formulas.
The exact formula we’re using here to calculate a 14DMA for the non-viral impressions is
=arrayformula( if(B3:B="",, sumif(row(B3:B),">"&(row(B3:B)-14),B3:B) - sumif(row(B3:B),">"&row(B3:B),B3:B) ) /if((row(B3:B)-2)>=14,14,row(B3:B)-2) )
We can see that impressions overall are falling and that viral impressions trending down as a percentage of impressions. You can see the relative difference between viral vs non-viral using a 100% stacked chart with a trendline for the non viral impressions. This makes it clear that there has been a small decrease in viral impressions as a % but not much actually and that mostly traffic is just decreasing to the Page.
notion image
notion image
notion image