Add external campaign identifier to CRM deal record
When a marketing system posts a campaign ID for a deal, that ID is saved on the deal in Pipedrive, so sales can see where the deal came from.
Install it
Set up this Zap for me, read how here: https://zapier.sh/zapier/awesome-zaps/add-external-campaign-identifier-to-crm-deal-record/
Paste into Claude, ChatGPT, Cursor or any agent.
- Category
- Sales · CRM management
- Author
- Zapier
- Source
- zapier/awesome-zaps, folder zaps/add-external-campaign-identifier-to-crm-deal-record
Set it up with the CLI
- Add it. Copies the folder into
zaps/add-external-campaign-identifier-to-crm-deal-record/. Outside a project, it makes one first.npx zap-pack add awesome-zaps/add-external-campaign-identifier-to-crm-deal-record - 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 add-external-campaign-identifier-to-crm-deal-record - Check it. Its recent runs, with status and errors.
npx zap-pack logs add-external-campaign-identifier-to-crm-deal-record
zaps/add-external-campaign-identifier-to-crm-deal-record/
- 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/pipedrive.tsThe
pipedriveaccount it uses - triggers/hook.tsWhat starts it:
webhookhook_v2 - 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 payload arrives at a Webhooks by Zapier catch hook (
webhook,hook_v2). A marketing tool, landing page or script posts to it. - Filter: the run continues only if the payload has both a deal ID (
deal_id) and an external campaign identifier. The identifier is taken fromcampaign_id, thenutm_campaign, thenexternal_id, whichever is present first. Otherwise the run stops and writes nothing. - Pipedrive looks up the deal by that ID. If the deal doesn't exist, or its external ID field already holds the same value, the run stops.
- Pipedrive updates the deal, overwriting its external ID field with the incoming value.
No new deals are created from webhooks.
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 |
|---|---|
EXTERNAL_ID_FIELD |
The key of the custom Pipedrive deal field that stores the external campaign identifier (Settings > Data fields) |
Defaults worth reviewing with them: the Zap overwrites whatever the field holds with the newest identifier. It does not only fill empty fields.
Prerequisite question: which payload fields carry the deal ID and the campaign ID? The code expects deal_id and one of campaign_id, utm_campaign or external_id. If the sender uses other names, change those keys in workflow.ts before installing.
Build it
If you can run shell commands, set it up with zap-pack: run npx zap-pack add awesome-zaps/add-external-campaign-identifier-to-crm-deal-record, replace each REPLACE_… value as this file says, then run npx zap-pack deploy add-external-campaign-identifier-to-crm-deal-record, 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
pipedriveto the user's Pipedrive connection, for the account that owns the deals. The webhook catch hook needs no account. - Source: publish
workflow.tsandconfig.ts, withEXTERNAL_ID_FIELDreplaced by the user's answer.triggers/hook.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, if it has one) before the first test run, and fix any key in
workflow.tsthat doesn't match.
Test it
Run this sample as a draft test, with deal_id set to a test deal in the user's Pipedrive account:
{
"deal_id": 123,
"campaign_id": "[install-test] spring-2026-webinar",
"utm_campaign": "spring-2026-webinar",
"external_id": "ext-0001"
}
Check that the deal's external ID field now shows [install-test] spring-2026-webinar, and no other field on the deal changed. Then send a second payload with no deal_id. It should stop at the filter and write nothing. If run-status tools aren't available, check the result in Pipedrive directly. Then publish, confirm the trigger is active, and give the user their webhook URL to point the sending system at. The user deletes test data, not the agent.
Notes
- Anyone with the webhook URL can write to the deal's external ID field. Keep the URL private.
- The overwrite rule keeps only the latest campaign in the field.
- If
deal_idis not a Pipedrive deal ID, the lookup stops the run and nothing is written. - To alert marketing ops when a payload is skipped, add a Slack or email step after the filter. To keep an audit trail, append a timestamped note with the original payload to the deal.