Increment company engagement totals from incoming marketing emails
Every marketing email engagement adds one to the engagement count of the company it belongs to, so campaign managers see who is engaging most.
Install it
Set up this Zap for me, read how here: https://zapier.sh/zapier/awesome-zaps/increment-company-engagement-totals-from-incoming-marketing-emails/
Paste into Claude, ChatGPT, Cursor or any agent.
- Category
- Data & Analytics · Analytics automation
- Author
- Zapier
- Source
- zapier/awesome-zaps, folder zaps/increment-company-engagement-totals-from-incoming-marketing-emails
Set it up with the CLI
- Add it. Copies the folder into
zaps/increment-company-engagement-totals-from-incoming-marketing-emails/. Outside a project, it makes one first.npx zap-pack add awesome-zaps/increment-company-engagement-totals-from-incoming-marketing-emails - Fill in the values in
config.ts, and in any other file the list marks. Replace each one as its comment and SKILL.md say. - Deploy it. Asks for any value still left, signs you in to Zapier if you aren't, then publishes it to your account.
npx zap-pack deploy increment-company-engagement-totals-from-incoming-marketing-emails - Check it. Its recent runs, with status and errors.
npx zap-pack logs increment-company-engagement-totals-from-incoming-marketing-emails
zaps/increment-company-engagement-totals-from-incoming-marketing-emails/
- README.mdWhat it does, for people
- SKILL.mdHow an agent sets it up: what to ask you, and how to test it
- config.tsIts settings 1 to fill in
- connections/hubspot.tsThe
hubspotaccount it uses - connections/zapier-tables.tsThe
zapier-tablesaccount it uses - triggers/email-event.tsWhat starts it:
hubspotemail_event - workflow.tsThe code; each
ctx.stepis a step in the Zap
Agents: add --yes to any command so it never prompts. When it needs an answer only the user can give, it stops and names the flag that supplies it.
SKILL.md
View MarkdownWhat it does
- Trigger: a new HubSpot email engagement event (
hubspot,email_event). It counts every event type unless one is set. - Filter: if the event has no related company IDs, the run stops and writes nothing.
- Loop: for each company ID, once, in the order given:
- Zapier Tables searches the tracking table for a row whose Company ID matches.
- If a row is found, Zapier Tables adds
INCREMENT_AMOUNTto its Engagement Count. - If not, Zapier Tables creates the row with that Company ID and an Engagement Count of
INCREMENT_AMOUNT.
- A company that fails is recorded in the run's output and doesn't stop the others.
The Zap only reads and writes the tracking table. It sends nothing to HubSpot.
Ask the user
Each REPLACE_… value is set per person. Resolve names to IDs with the user's own connections; don't ask them to paste an ID you can look up.
| Setting | What goes there |
|---|---|
REPLACE_TABLE_ID |
The Zapier Table that holds the company engagement counts, the one with Company ID and Engagement Count columns. Look it up with the user's Zapier Tables connection. |
Also review the defaults with them:
COMPANY_ID_FIELDandENGAGEMENT_COUNT_FIELD: the table's field keys, which are generated per table (data__f1anddata__f2in the test table). Check them against the table before the first test run.INCREMENT_AMOUNT("1"): how much each engagement adds.- The trigger's event type in
triggers/email-event.ts: unset counts every HubSpot email event. Set it to one type, such asOPENorCLICK, to count only that type.
Build it
If you can run shell commands, set it up with zap-pack: run npx zap-pack add awesome-zaps/increment-company-engagement-totals-from-incoming-marketing-emails, replace each REPLACE_… value as this file says, then run npx zap-pack deploy increment-company-engagement-totals-from-incoming-marketing-emails, which signs the user in to Zapier when it gets there. Otherwise build with Zapier MCP, as the steps below say. No Zapier MCP tools? Read https://docs.zapier.com/mcp/get-started/quickstart.md and follow the page for the app you are running in to get the user connected, then continue with this build.
- Accounts: bind
zapier-tables(the Zapier Tables connection that owns the tracking table) andhubspot(the HubSpot account the trigger watches for email events). - Source: publish
workflow.tsandconfig.ts, withREPLACE_TABLE_IDreplaced by the user's answer.triggers/email-event.tsandconnections/are settings, not code: set the workflow's trigger and connection bindings from them. The trigger file names the app by its slug; for the trigger'sselected_api, callsearch_triggerswith that slug, find the row whosekeyis the trigger'sevent, and use<app_key>@<app_version>from it. - Build guide: load Zapier's build guide with
get_zapier_skill("zapier:build-workflows")and follow it to create, test and publish the workflow. - Fields: inspect each action's fields with the user's connections and sample the trigger before the first test run, and fix any key in
workflow.tsthat doesn't match. The create step writesnew__data__f1andnew__data__f2directly, so match those to the table's keys too.
Test it
Run this sample as a draft test (run_workflow_draft) before publishing, with two company IDs that aren't in the table yet:
{
"associatedCompanyIds": ["install-test-co-1001", "install-test-co-1002"]
}
The first run should create one row per company, each with an Engagement Count of 1. Run it again: both rows should reach 2. If run-status tools aren't available, check the rows in Zapier Tables directly. Publish only after both runs pass. The user deletes the test rows, not the agent.
Notes
- Find-then-create is not atomic. If two events for a company with no row arrive at the same moment, the table can end up with two rows for it, and each count only includes its own event.
- A HubSpot event may relate to more than one company; each one is counted once per event.
- Anyone who can edit the table can change its counts, so keep it private to the team that reads it.
- If HubSpot's payload uses another name for the related company IDs, change it in the input schema and the filter in
workflow.tsbefore publishing. - To extend it: aggregate events into daily batches so each company updates once a day, or weight increments by type, so a click counts more than an open.