Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every hour ClickRuntime checks your store for product categories it has not seen before.

  2. For each new category, it finds orders from the last year that included products from the related parent category.

  3. Each customer is added once to your campaign sheet with their name, email and a Not sent status.

  4. 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

RunsEvery hour
Build customer lists for new-category campaignstoday, 9:00Succeeded
Google Sheets · CampaignsLinen Bedding · Sam · sam@example.com · Not sent Linen Bedding · Priya · priya@example.com · Not sent

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
customer_campaign_lists_from_woocommerce_in_a_sheet.pyexample
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?
By the new category's parent category. You can instead name the categories to match in the prompt.
Does it respect marketing consent?
It lists customers and their email; make sure you only contact people who agreed to marketing, for example by filtering on your consent field.
Can it create a coupon for the campaign?
Yes, with a read and write key. A coupon code can be created and added to each row.
What permissions does it need?
WooCommerce read (+write for coupons); Sheets write. Nothing else in your accounts is used.
Does it need AI?
No, but you can ask for an AI step (for example a summary). It then uses ClickRuntime's built-in AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.