Enrich ChartMogul customers when a HubSpot deal closes
When a deal is marked closed won in HubSpot, we tag the matching ChartMogul customer with the plan and source, and record the sale details.
Build a code workflow that mirrors the commercial context of every won sale from HubSpot onto the matching ChartMogul customer, so revenue reporting can be segmented by how the deal was actually sold. Use the HubSpot poll trigger "Deal Created, Updated, or Stage Changed" (event type deals_updated) so the workflow runs whenever a deal is created, edited, or moved between stages.
First, check the stage of the deal that fired the trigger. Only continue if the deal is in a closed won stage. The stage filter belongs inside the workflow, not in the trigger. If the deal is in any other stage, exit immediately without writing anything and without treating it as an error. If the trigger payload does not carry the full deal record, read it back with HubSpot Search Deals filtered on the deal id.
For a closed won deal, use HubSpot Search Contacts to find the primary contact associated with the deal and read their email address. That email is the join key between the two systems. If the deal has no associated contact with a usable email address, exit cleanly and say why.
Look the customer up with ChartMogul Search Customers by Email. Treat an empty result as a normal outcome rather than a failure: billing frequently starts days after a deal closes, so the customer may not exist in ChartMogul yet. In that case, log that no customer matched and finish successfully. The next time the deal is touched in HubSpot the workflow runs again, and by then the customer will usually exist.
When a customer does match, apply tags with ChartMogul Add Tags to Customers by Email. Tag the plan tier the deal was sold at, and the acquisition source (for example the deal's lead source or original channel). Tags are additive, so this must not disturb tags already on the customer.
Then write the structured fields with ChartMogul Add Custom Attributes to Customers by Email: deal owner as a String, deal amount as an Integer, close date as a Timestamp, and contract term as a String. Two details matter here. ChartMogul custom attribute types are capitalized exactly as String, Integer, Decimal, Timestamp and Boolean. And ChartMogul monetary amounts are integers in cents, so multiply the HubSpot deal amount by 100 and round to a whole number before sending it. Send the close date as an ISO 8601 timestamp.
Optionally call ChartMogul Retrieve a Customer's Tags and Attributes afterwards to confirm the write landed, and include the tags and attributes that were applied in the run output so each run is auditable. Keep the field mapping fixed and deterministic. There is no judgement to make at any step, so no model reasoning is needed.
Additional information
What does this prompt do?
- Watches your HubSpot pipeline and picks up every deal that moves into a closed won stage.
- Finds the matching customer in ChartMogul using the email address of the main contact on the deal.
- Tags that customer with the plan tier they bought and where the deal came from, so revenue can be sliced by both later.
- Records the deal owner, the deal value, the close date and the contract length on the customer record.
What do I need to use this?
- A HubSpot account with deals and contacts, where closed won deals have a contact with an email address on them.
- A ChartMogul account that already has your billing data flowing into it.
- Agreement on which HubSpot fields hold the plan tier, the acquisition source and the contract term.
How can I customize it?
- Change which pipeline stages count as a win, if your team uses custom stage names.
- Swap in different details to tag or record, such as region, industry or the partner who referred the deal.
- Adjust which contact on the deal is used for matching, for example the billing contact instead of the main one.
FAQs
What happens if the customer is not in ChartMogul yet?
Will this work on HubSpot Free?
Does this change anything in HubSpot?
Will it overwrite tags I already added in ChartMogul?
How soon after a deal closes does the customer get updated?
Related templates
Every new form submission gets judged real or junk, sorted by intent, and only genuine sales leads land in HubSpot with an email brief waiting for your team.
When a contract is fully signed, we read the agreed terms, move the matching HubSpot deal to closed won, and post a deal desk summary to Slack.
When a DocuSeal document is fully signed, the answers people typed become real HubSpot records, with the executed PDF filed in Drive.
When a new contact lands in HubSpot, we read their company website and recent news, fill in the record, and send their owner a short brief.
When a customer signs but your side has not, this alerts the internal signer in Slack with the deal value and re-sends their signing email.
Every weekday at 7am we check your bounce and spam complaint rates, and only message you in Slack when something is actually going wrong.
Stop guessing which deals actually drive your MRR.
Let every closed won deal carry its sales context into ChartMogul, so your revenue reporting segments itself.