We’re in need of a way to target an email marketing campaign to contacts whenever a new company offering our product opens within the contact's area. The contact information is accumulated in the HubSpot Contacts object and the data we collect for a contact is pretty basic (name, postal code, email address). The HubSpot Companies object will contain the list of companies offering our product which will updated from our ERP using a PieSync integration, and there's a lot more data available on the company, such as full address, city, and possibly even latitude and longitude. When a new company offering our product is identified by the workflow, then we want to send an email to all contacts within a designated radius of the new company to inform the contact of the new availability. Using a HubSpot workflow we want to detect the new company offering our product, filter the contact list to those within a specified distance from the company, pass the filtered list to the next step, and send a templated email to the list of filtered contacts. I was thinking of using the Haversine formula to estimate distance between the company (latitude and longitude) and the contact (using a list of all US postal codes with a latitude and longitude for each).
Great use case of custom code! There is an app for this on the marketplace already, called Map My Customers, maybe this can serve as inspiration/reference.
Best regards!
Karsten Köhler HubSpot Freelancer | RevOps & CRM Consultant | Community Hall of Famer
Update: Using Operations Hub I've utilized a workflow containing custom code to detect a new company, calculate the distance between the new company and all our marketing contacts who've opted to receive updates, update contact properties to contain company information, programmatically create an active list to contain the contacts in proximity to the company, programmatically create a workflow to monitor enrollment in the active list to send emails to contacts added to the list.I created several custom properties on Contacts and Companies to contain data needed for the workflows.Since we are limited to knowing only the zip code of a contact, I created HubDB tables to contain the latitude and longitude of zip codes in the United States, which are then used for the proximity calculation.So, this one workflow spawns another workflow and creates an active list for each new company, which if you have many companies can get a little messy. I could not find a way to programmatically move the workflow and active list to a folder, so I manually move the new workflows and list to a folder, for now.But, overall the workflow does serve our purpose until we have the feature built-in to HubSpot.
Can you share your code to do this? I'm looking to do something very similar. I want to be able to filter all customers within a specific radius and I think what you did is almost exactly the same thing.
Is there a solution for this problem without paying for a third-party integration or using Operations Hub? We are already using Marketing, Sales & Service Hubs and don't want to pay for Ops Hub for a marketing email issue...
Update: Using Operations Hub I've utilized a workflow containing custom code to detect a new company, calculate the distance between the new company and all our marketing contacts who've opted to receive updates, update contact properties to contain company information, programmatically create an active list to contain the contacts in proximity to the company, programmatically create a workflow to monitor enrollment in the active list to send emails to contacts added to the list.I created several custom properties on Contacts and Companies to contain data needed for the workflows.Since we are limited to knowing only the zip code of a contact, I created HubDB tables to contain the latitude and longitude of zip codes in the United States, which are then used for the proximity calculation.So, this one workflow spawns another workflow and creates an active list for each new company, which if you have many companies can get a little messy. I could not find a way to programmatically move the workflow and active list to a folder, so I manually move the new workflows and list to a folder, for now.But, overall the workflow does serve our purpose until we have the feature built-in to HubSpot.
This is a really interesting use case! I think it might be useful if you attend next week's Workshop on Custom Code Actions (June 2, 11 AM EST).
You can submit this use case during the workshop. The hosts can then discuss live how to best approach and design this solution and they can help you figure out how to build such a workflow using custom code.
Great use case of custom code! There is an app for this on the marketplace already, called Map My Customers, maybe this can serve as inspiration/reference.
Best regards!
Karsten Köhler HubSpot Freelancer | RevOps & CRM Consultant | Community Hall of Famer