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
The moment a deal hits Closed Won, the right contract starts in Ironclad, the link lands on the deal, and your sales channel hears who owns the next step.
When a deal is marked closed won in HubSpot, the matching order is drafted in ERPNext with the right customer attached, ready for finance to review.
The moment a job posting matches your ideal customer profile, check what the company already runs, log the account in HubSpot, and alert your sales channel.
When a deal reaches proposal or demo, we pick the right collateral, create a unique tracked link for that buyer, and hand it to the rep.
Every new service request in Jobber becomes a HubSpot contact and deal, plus an instant Slack alert so your team can call the customer back the same day.
Every new contact triggers a read of the company's own website, so reps open the first call already knowing what they sell and who they sell to.
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.