On a schedule
Log daily website KPIs and get alerted when one drops
Every day yesterday's key numbers go into a sheet, and you are alerted in Slack and by email if any falls well below its recent average.
- Runs
- On a schedule
- Apps
- Google Analytics, Google Sheets
- AI
- Optional
- Access
- GA4 Viewer; Sheets write
Send this to your assistant
Create a ClickRuntime automation: every morning, add yesterday's GA4 sessions, conversions and revenue to my KPI sheet. If any is more than 25% below its 7-day average, post an alert to #marketing and email me.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
An online shop watches three numbers: visits, orders and revenue. When one falls, the team wants to know the next morning, not when the month-end report comes out. Checking GA4 every day is a chore that gets dropped during busy weeks.
Logging the numbers daily and alerting only on a real drop gives the team a reliable history and a fast warning, without anyone checking a dashboard.
What you get out of it
Problems caught the next morning
A sharp fall in orders or revenue is flagged within a day.
A daily log for charts
One row per day makes it easy to chart the numbers and spot patterns.
Quiet on normal days
Alerts only go out when a number really drops, so they are taken seriously.
Optional explanation
With AI on, the alert includes a likely reason, such as a traffic source that fell away.
How it works
What happens, step by step
Every morning, ClickRuntime asks Google Analytics for yesterday's sessions, conversions and revenue.
It adds them as a new row in your KPI sheet.
It compares each number with the average of the previous seven days in the sheet.
If any is more than 25% lower, an alert goes to your #marketing Slack channel and your email, with a short AI explanation if available.
Before it runs live
- Connect Google Analytics
- 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
- Change what the AI looks for, or how it writes the result
- Add another app, for example also send it to Slack
- Combine it with other Google Analytics 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, http, credentials, ai, notify
def api(name, version):
return build(name, version, credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
PROPERTY = "123456789"
def ga(body):
url = f"https://analyticsdata.googleapis.com/v1beta/properties/{PROPERTY}:runReport"
return http.post(url, headers={"Authorization": f"Bearer {credentials.connection('google', 'work')}"}, json=body).json().get("rows", [])
SHEET_ID = "your-spreadsheet-id"
METRICS = ["sessions", "conversions", "purchaseRevenue"]
@on_trigger
def run(event):
r = ga({"dateRanges": [{"startDate": "yesterday", "endDate": "yesterday"}], "metrics": [{"name": m} for m in METRICS]})
today, drops = [float(v["value"]) for v in r[0]["metricValues"]] if r else [0.0] * 3, []
sheet = api("sheets", "v4").spreadsheets().values()
past = sheet.get(spreadsheetId=SHEET_ID, range="KPIs!A2:D").execute().get("values", [])[-7:]
sheet.append(spreadsheetId=SHEET_ID, range="KPIs!A:D", valueInputOption="RAW", body={"values": [[(date.today() - timedelta(days=1)).isoformat()] + today]}).execute()
for i, name in enumerate(METRICS):
if (avg := sum(float(row[i + 1]) for row in past) / len(past) if past else 0) and today[i] < avg * 0.75:
drops.append(f"{name}: {today[i]:,.0f} vs 7-day average {avg:,.0f} ({(today[i] - avg) / avg * 100:.0f}%)")
if not drops:
return {"alerts": 0}
text = "\n".join(drops)
try: text += "\n\n" + ai.generate(text, system="Give the most likely reason for these drops in 2 sentences.", max_output_tokens=120).text
except ai.AIError: pass
notify.slack(f"📉 KPI drop yesterday\n{text}", channel="#marketing")
notify.email_me("KPI drop yesterday", text)
return {"alerts": len(drops)}FAQ
Common questions
Why compare with the 7-day average?
Where do alerts go?
Can it alert on rises too?
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
Log your weekly website numbers to a sheet
Every week your key GA4 numbers are added as a row in your reporting sheet, and you get an email summarising what changed.
See how it worksWrite a monthly search traffic report to a sheet
Each month, organic search traffic by landing page is written to a sheet with the change from the month before, and you get an email listing the best opportunities.
See how it worksLog daily GA4 traffic by source to Google Sheets
Each morning yesterday's GA4 sessions, users and key events per source / medium are appended to a Traffic tab.
See how it worksKeep exploring
Set up “Log daily website KPIs and get alerted when one drops” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.