Send closed won HubSpot deals into your Segment analytics

By General Input

When a deal is marked Closed Won, the revenue and the account behind it flow straight into your customer data platform, so product analytics knows who actually paid.

Integrations

  • Twilio Segment
  • HubSpot
  • Slack

Type

Agentic Task

Categories

  • Sales
  • Product

When a deal changes stage in HubSpot, close the loop between revenue and product analytics by pushing the win into Segment. Trigger this on a HubSpot webhook subscribed to deal stage changes. The subscription fires on every stage change, so the workflow itself has to filter: read the new stage from the webhook payload, and if it is anything other than Closed Won, stop immediately and do nothing. Do not post to Slack and do not send any tracking calls for deals that landed in some other stage.

When the new stage is Closed Won, use HubSpot "Get Deal" to fetch the full deal by its id, requesting the properties I care about (deal name, amount, currency, close date, pipeline, deal stage and deal owner) along with its associations to contacts and companies. Then take the primary associated contact and use HubSpot "Get Contact" to fetch it, so I have the contact's email address, name and company.

Send three calls into the Segment source I choose during setup. First, Segment "Identify User" for that contact, keyed on a stable identifier such as their email or HubSpot contact id, with traits including email, name, company and plan. Second, Segment "Group User" associating that user with their company account, keyed on the company domain or HubSpot company id, with group traits including the company name, domain and the value of the deal that just closed. Third, Segment "Track Event" with the event name "Deal Closed Won", carrying amount, currency, pipeline and deal owner as event properties, plus the HubSpot deal id and close date so the event can be traced back to the CRM record.

Three implementation details matter here. Segment tracking calls authenticate with a Source WRITE KEY, which is a different credential from the Segment Public API token, so setup must ask me which Source to write into and resolve that Source's write key rather than assuming the API token is enough. Derive a stable messageId for each call from the HubSpot deal id combined with the stage, so duplicate webhook deliveries do not double count revenue. Segment de-duplicates on messageId within a 24 hour window. Finally, Segment rejects data sent to the wrong region, so the US or EU host must match my workspace region.

Use judgement on incomplete records rather than failing the whole run. If the deal has no associated contact, or the contact has no email address, skip the identify and track calls that depend on a user identity and send only the group call keyed on the company domain, so the closed revenue is still captured against the account. If the deal is missing an amount or a currency, send what you do have and note the gap in the Slack message instead of erroring out.

Finish by using Slack "Send a Message" to post a short note in my revenue channel confirming which deal was synced (deal name, amount and owner) and which calls were sent, including a clear note when the contact was missing and only the group call went through. Keep it to a couple of lines, readable at a glance.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredTurn Mailjet email clicks into ranked HubSpot follow-upsiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe reveals