Every hour
Build customer lists for new-category campaigns
When you add a new product category, customers who bought related products are pulled into a sheet, ready for a campaign.
- Runs
- Every hour
- Apps
- Google Sheets, WooCommerce
- AI
- Optional
- Access
- WooCommerce read (+write for coupons); Sheets write
Send this to your assistant
Create a ClickRuntime automation: every hour, check my WooCommerce store for new product categories. For each, find customers who bought from the related parent category in the last year and add them to a Campaigns sheet with a Not sent status.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
When a shop launches a new range, the best first buyers are customers who already bought something similar. Finding them means exporting orders, filtering by product and de-duplicating in a spreadsheet, which most small shops never get round to.
Building the list as soon as the category appears means the campaign can go out on launch day. The sheet tracks who has been contacted, so nobody is messaged twice.
What you get out of it
Launch to the right people
Customers who bought related products are the likeliest to buy the new range.
Ready on launch day
The list is built within the hour of adding the category, with no exports to run.
Track who was contacted
A status column shows who has been sent the campaign, avoiding duplicates.
Works with any sending tool
The sheet can be imported into your email or messaging tool, or sent from by another automation.
How it works
What happens, step by step
Every hour ClickRuntime checks your store for product categories it has not seen before.
For each new category, it finds orders from the last year that included products from the related parent category.
Each customer is added once to your campaign sheet with their name, email and a Not sent status.
The category is remembered, so its list is only built once.
Before it runs live
- Connect your Google Sheets account and pick the spreadsheets it may use
- Connect WooCommerce
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
- Act only on the items that match your own rules, and skip the rest
- 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 Sheets and WooCommerce 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 datetime, timedelta, timezone
from clickruntime import on_trigger, report_fetched, credentials, http, state
SHEET_ID = "your-spreadsheet-id"
STORE = "https://yourstore.com/wp-json/wc/v3"
def wc(method, path, **kw):
resp = http.request(method, STORE + path, auth=(credentials.secret("WC_CONSUMER_KEY"), credentials.secret("WC_CONSUMER_SECRET")), **kw)
resp.raise_for_status()
return resp.json()
def sheets():
return build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets().values()
@on_trigger
def run(event):
known = state.get("categories")
cats = wc("GET", "/products/categories", params={"per_page": 100})
new = [c for c in cats if known is not None and c["id"] not in known and c["parent"]]
report_fetched(len(new))
if known is None or new:
state.set("categories", [c["id"] for c in cats])
if not new:
return {"lists": 0}
after = (datetime.now(timezone.utc) - timedelta(days=365)).strftime("%Y-%m-%dT%H:%M:%S")
orders = wc("GET", "/orders", params={"after": after, "per_page": 100, "status": "completed"})
for c in new:
product_ids = {p["id"] for p in wc("GET", "/products", params={"category": c["parent"], "per_page": 100})}
buyers = {o["billing"]["email"]: o["billing"]["first_name"] for o in orders
if any(li["product_id"] in product_ids for li in o["line_items"])}
rows = [[c["name"], name, email, "Not sent"] for email, name in buyers.items()]
if rows:
sheets().append(spreadsheetId=SHEET_ID, range="Campaigns!A:D", valueInputOption="RAW", body={"values": rows}).execute()
return {"lists": len(new)}FAQ
Common questions
How is "related" decided?
Does it respect marketing consent?
Can it create a coupon for the campaign?
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
Write SEO titles and descriptions for your products
Products you list in a sheet get AI-written SEO titles and meta descriptions in WooCommerce, with progress tracked in the sheet.
See how it worksAdd products to WooCommerce from a sheet
New rows in your product sheet become WooCommerce products with AI-written descriptions, and stock changes in the sheet are kept in sync.
See how it worksClean up product images from a sheet queue
Products you list in a sheet get new clean-background images made and attached in WooCommerce.
See how it worksKeep exploring
Set up “Build customer lists for new-category campaigns” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.