On a schedule
Log Facebook Page insights to Google Sheets daily
Yesterday's Facebook Page views, post engagements, new follows and media views are added to a sheet as one row per day.
- Runs
- On a schedule
- Apps
- Facebook Pages, Google Sheets
- AI
- Not needed
- Access
- pages_show_list, pages_read_engagement, read_insights; Google Sheets read+write
Send this to your assistant
Create a ClickRuntime automation: every morning at 6, add yesterday's Facebook Page insights (page views, post engagements, new follows, unfollows and media views) to the Page stats tab of my sheet.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Meta Business Suite shows Page insights, but only for windows it chooses, and exporting means downloading a file each time. Comparing this month with the same month last year is awkward without your own history.
This automation adds one row a day to a sheet with the Page's views, engagements, follows, unfollows and media views, so you build a complete record you control.
Social media managers, small businesses and agencies reporting to clients use the tab as the source for monthly charts.
What you get out of it
History you own
Daily numbers stay in your sheet even after Meta changes what its dashboards show.
Easy monthly reports
Sum a month's rows or chart them; no exports needed.
Follows and unfollows side by side
See whether a post or campaign brought in followers or lost them.
Several Pages, one sheet
Ask for one tab per Page to compare locations or brands.
Adjustable metrics
Swap metric names at the top of the script to track what matters to you.
How it works
What happens, step by step
Every morning ClickRuntime asks Facebook for your Page's insights for the previous day.
It reads views, post engagements, new follows, unfollows and media views.
One row with the date and each number is added to your Page stats tab.
Over time the tab becomes a daily history you can chart.
Before it runs live
- Connect Facebook Pages
- Connect your Google Sheets account and pick the spreadsheets it may use
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Facebook Pages and Google Sheets steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from datetime import date, timedelta
from clickruntime import on_trigger, credentials, http
PAGE_ID = "1234567890"
SHEET_ID = "your-spreadsheet-id"
METRICS = ["page_views_total", "page_post_engagements", "page_daily_follows_unique", "page_daily_unfollows_unique", "page_media_view"]
def page_token():
r = http.get(f"https://graph.facebook.com/v21.0/{PAGE_ID}", params={"fields": "access_token",
"access_token": credentials.connection("facebook", "work")})
r.raise_for_status()
return r.json()["access_token"]
@on_trigger
def run(event):
day = date.today() - timedelta(days=1)
data = http.get(f"https://graph.facebook.com/v21.0/{PAGE_ID}/insights", params={
"metric": ",".join(METRICS), "period": "day", "since": day.isoformat(), "until": date.today().isoformat(),
"access_token": page_token()}).json().get("data", [])
values = {m["name"]: (m["values"][-1].get("value", 0) if m.get("values") else 0) for m in data}
row = [day.isoformat()] + [values.get(m, 0) for m in METRICS]
build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False) \
.spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Page stats!A:F", valueInputOption="RAW",
body={"values": [row]}).execute()
return {"date": day.isoformat(), **values}FAQ
Common questions
Which permissions does my Facebook app need?
Why is a metric showing zero?
Can I backfill past months?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Export Meta Ads results to Google Sheets every day
Every morning yesterday's spend, clicks and conversions for each campaign are added to your sheet, and you get a short summary by email.
See how it worksLog Facebook Page post stats to Google Sheets
Every Monday a Posts tab is rewritten with each Facebook Page post from the last 30 days and its reactions, comments, shares and link.
See how it worksPost about trending topics on Facebook and log each post
Each day a post about a trending topic in your field goes out on your Facebook Page, and it's logged in your sheet with its link.
See how it worksKeep exploring
Set up “Log Facebook Page insights to Google Sheets daily” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.