Implementation
Link child companies to the right parent company in HubSpot – automatically, with suggestions when it's unclear
Chains and franchises become many companies in HubSpot. How a workflow with custom code links them to the right parent company.
By Viktor Olsson, founder and RevOps consultant
Implementation · RevOps· 9 min read
HubSpot can link new companies to the right parent company automatically, but not with its standard settings. HubSpot associates contacts with companies by the domain in their email address. It doesn't link a new company to the chain or group it belongs to. We built that for a B2B company whose customers often have several locations: a workflow with custom code that finds the likely parent company, links it when the match is certain, and otherwise leaves a suggestion for the company owner.
Why parent companies matter in HubSpot
HubSpot lets you link companies as a parent company and its child companies. That link drives a lot:
- Reports per group or chain, such as revenue per group and how many locations are customers.
- Who owns the customer. A chain often has one customer success manager (CSM) for the whole group.
- Expansion. A restaurant in a chain where three others are already customers is a warmer lead than an unknown restaurant.
The problem is that new companies rarely arrive with a clear link. They are created by an integration or a form, and the name doesn't follow the group's name. A franchise is often named after its city. A store in another country can have the group's name but another top-level domain. CSMs link them by hand when they have time, and the rest stay unlinked.
Why domain matching alone doesn't work
Most teams start by matching on the domain. That works for single companies, but not for chains:
- Franchises often have their own domains, or none at all.
- The same brand exists on several top-level domains, such as
northwindcoffee.seandnorthwindcoffee.no. - A new company often has no domain when it is created. It is filled in later, by an integration or a person.
- Webmail such as
gmail.comsays nothing about which company it is.
HubSpot also has only one automatic association per domain. If several companies share a domain, contacts are associated with only one of them, and you can't choose which.
How each possible parent company is scored
Every company marked as a parent (in our case a custom field, "Is group parent" = Yes) is a candidate. The code scores each one:
| Signal | Points | Why |
|---|---|---|
Same root domain (oslo.acmehotels.com = acmehotels.com) |
+60 | The strongest signal. Your own domain and webmail such as gmail.com don't count. |
Same brand on another top-level domain (acmehotels.com and acmehotels.de) |
+35 | The same group in another country. |
| The company's name contains the parent's name or one of its keywords | up to +55 | "Acme Hotels Berlin" contains "Acme Hotels". |
| Same customer success manager (CSM) | +10 | Only ranks, never decides. |
| Same owner in HubSpot | +5 | Only ranks, never decides. |
The CSM and the owner get few points on purpose. One person owns many customers that have nothing to do with each other, and on a new company those fields are often empty.
For groups whose locations share neither a name nor a domain, there is a keywords field on the parent. Put harbour view and old mill lodge there, and those companies get a suggestion even though their names don't look like the group's.
When should the automation link, and when should it only suggest?
The code only links when two things agree: the same root domain and a name similarity of at least 90%. The best parent must also be at least 15 points ahead of the runner-up. Everything else becomes a suggestion.
| Situation | Status | What happens |
|---|---|---|
| Domain and name point to the same company, with a clear margin | Linked | The company is linked to the parent. |
| 35 points or more, but not both signals | Suggested | The suggestion is written on the company and the owner gets a task. |
| Two candidates within 15 points of each other | Ambiguous | The owner gets a task with both names. |
| No candidate reaches 35 points | No match | Nothing. Most new companies stand alone. |
| Already has a parent, or is one | Skipped | Existing links are never changed. |
The rule is deliberately strict. A looser rule linked more in our tests, but an automatic link nobody looks at must not be wrong. So we chose fewer automatic links and as few wrong ones as possible. In a test against a list the client had reviewed by hand, no link was wrong, and almost every suggestion pointed at the right group. So most of the time, the owner only has to confirm the suggestion.
Every run writes the status, score, suggestion, reason and time on the company. That makes it easy to see why something was or wasn't linked, and to build a view of all the suggestions waiting for review.
The workflow in HubSpot
Company is created, or Part of group = Yes
Wait 1 hour
Find and score parent companies
Match status
Ask the owner: is this company part of the suggested group?
Swipe sideways to see the whole flow.
- Trigger. The workflow starts when a company is created, or when someone sets Part of group to Yes. The second lets someone run a company through again, so re-enrollment is turned on for that trigger.
- Wait an hour. New companies are often created by an integration that fills in the domain and owner a little later. Without the wait, there is nothing to match on.
- Custom code. The code fetches the candidates, scores them, links or writes a suggestion, and returns status, score and suggestion as outputs to the workflow.
- Branch on status. Suggestions and ambiguous matches create a task for the company owner, with the reason in the notes. Linked and unmatched companies need nothing more.
Custom code in workflows needs Data Hub Professional or Enterprise (formerly Operations Hub). When you turn the workflow on, HubSpot asks whether to enroll existing companies. Say no, or it runs on every company in the account. Existing companies are better handled with a one-off script.
The hard part: AI for groups that rules can't find
The rules don't find everything. A location named after its street address, with no domain, gets no matches. So we designed a second version, where the workflow only sends the company's ID to a service outside HubSpot. The service handles what custom code can't:
- Reads more evidence. Besides the company's own fields, it reads the email domains of the company's contacts. A contact at
@acmehotels.comon a company called "Harbour View Hotel" is a strong clue. - Finds candidates without AI. Up to about twenty companies in HubSpot, from name, domain and keywords, scored the same way as above.
- Lets an AI model research. Google's Gemini, with web search, decides whether the company stands alone or is part of a group. If it is part of one, Gemini also works out what the group is called and its domain.
- Lets the code decide. The AI can only point at candidates the service already found. It can never invent a HubSpot ID. The rules decide whether the answer becomes a link, a suggestion or nothing. If the AI call fails, the rules apply on their own.
When the first company from a new group arrives, only the group's name and domain are saved. When the next company from the same group arrives, the service links the companies and picks one of them as the parent. That is the head office if the AI found it. Otherwise it is the company carrying the group's name and domain, and as a last resort the oldest customer.
Two companies in the same group are often created within the same hour. HubSpot's search doesn't find a new company until a few seconds later. So the service locks the group while it links the companies, and only one run at a time can pick the parent.
Clean data is a prerequisite for both the rules and the AI. There is more on duplicates and clean-up in Clean up HubSpot before AI agents.
More integrations we have built around HubSpot: customer requests from the company record to Linear and translating the knowledge base with Phrase.
Common questions
Can HubSpot associate child companies with a parent company automatically? Not with its standard settings. HubSpot associates contacts with companies by domain, but it doesn't link companies to each other. With custom code in a workflow, which needs Data Hub Professional or Enterprise, it can be built.
Do you need Data Hub to use custom code in workflows? Yes, custom code needs Data Hub Professional or Enterprise, which used to be called Operations Hub. Check what your licence includes under Account & Billing in HubSpot before you start building.
Does the automation change existing parent links? No. A company that already has a parent is skipped. If you remove a wrong link by hand, the workflow doesn't run again until someone triggers it for that company again.
Can the automation run on companies already in HubSpot? Yes, but not by enrolling every existing company in the workflow. Run a one-off script that goes through them and writes the same status, and let the workflow handle new companies.
Why not let the AI link the companies directly? Because an AI model can be confidently wrong. We only let it choose among candidates the code found, and the rules decide whether its answer is enough for a link. Uncertain cases become suggestions that a person approves.
How do you add a parent company in HubSpot? Open the company record, find the parent company section and choose the parent. Many companies can also be linked at once with an import. Automation is only needed when new companies keep arriving.
About the author
Viktor Olsson, founder and RevOps consultant
Viktor has worked with HubSpot for six years, with teams from 3 people to organisations with 30 sales reps across the Nordics. He also works in RevOps at an international SaaS company.