On a schedule
Log 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.
- Runs
- On a schedule
- Apps
- Facebook Pages, Google Sheets
- AI
- Not needed
- Access
- pages_show_list, pages_read_engagement; Google Sheets read+write
Send this to your assistant
Create a ClickRuntime automation: every Monday at 7am, refresh the Posts tab of my sheet with each post on my Facebook Page from the last 30 days: date, first line of text, reactions, comments, shares and link.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Knowing which posts worked is the basis of a content plan, but Facebook's post list is hard to sort and compare. Most people end up guessing from memory which topics did well.
This automation rewrites a Posts tab every Monday with the Page's posts from the last 30 days, their reactions, comments and shares, sorted with the strongest posts first.
Small business owners, social media managers and agencies use the tab in their weekly content meeting.
What you get out of it
Best posts at the top
Sorting by total interactions shows at once which topics and formats people responded to.
Ready for the weekly meeting
The tab is fresh every Monday morning without anyone exporting data.
First line of each post
The opening text helps identify posts without opening Facebook.
Comments counted separately
High comment counts point to posts that started conversations, not just likes.
Links to each post
Open a post directly to reply to comments or reuse it.
How it works
What happens, step by step
Every Monday ClickRuntime lists the posts your Page published in the last 30 days.
For each post it reads the reaction, comment and share counts.
The Posts tab is rewritten, sorted by total interactions, so the best posts are at the top.
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, report_fetched
PAGE_ID = "1234567890"
SHEET_ID = "your-spreadsheet-id"
FIELDS = "message,created_time,permalink_url,shares,reactions.summary(total_count).limit(0),comments.summary(total_count).limit(0)"
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):
url, params = f"https://graph.facebook.com/v21.0/{PAGE_ID}/published_posts", {
"fields": FIELDS, "since": (date.today() - timedelta(days=30)).isoformat(), "limit": 100, "access_token": page_token()}
posts = []
while url:
page = http.get(url, params=params).json()
posts += page.get("data", [])
url, params = (page.get("paging") or {}).get("next"), None
report_fetched(len(posts))
rows = []
for p in posts:
reactions = p.get("reactions", {}).get("summary", {}).get("total_count", 0)
comments = p.get("comments", {}).get("summary", {}).get("total_count", 0)
shares = p.get("shares", {}).get("count", 0)
text = (p.get("message") or "").split("\n")[0][:120]
rows.append([p["created_time"][:10], text, reactions, comments, shares, reactions + comments + shares, p["permalink_url"]])
rows.sort(key=lambda r: -r[5])
tab = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets().values()
tab.clear(spreadsheetId=SHEET_ID, range="Posts!A:G").execute()
tab.update(spreadsheetId=SHEET_ID, range="Posts!A1", valueInputOption="RAW", body={"values": [
["Date", "Post", "Reactions", "Comments", "Shares", "Total", "Link"]] + rows}).execute()
return {"posts": len(rows)}FAQ
Common questions
Why only the last 30 days?
Can it include reach or views per post?
Does it include posts by visitors?
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 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.
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 post stats to Google Sheets” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.