
How to Automate Lead Scoring from PostgreSQL to Hubspot?
By Othmane Lamrani · May 24, 2022 · 7 min read
You are a big fan of the marketing tools in Hubspot but the fact that the data went into a separate system fazed you (not literally).
Don’t worry, here I show two ways to load PostgreSQL data into Hubspot so that you can remove the PostgreSQL ETL jobs and have actual real-time data in Hubspot.
Once accomplished, you’ll be able to:
- Build customized audiences and create customized marketing campaigns for different audiences
- Personalized Lifecycle Marketing: send the right message at the right time
- Automate lead score: to close more deals
We are going to focus on automating lead scoring in this article.
Summary
What is PostgreSQL?

PostgreSQL is an open-source relational database that is known for its stability, flexibility, and rich feature set.
It has been around since the early 90s and has been used by many large companies, including Facebook, Netflix, and Twitter.
What is Hubspot?

HubSpot is a marketing platform that helps businesses grow their traffic, leads, and sales through inbound marketing strategies.
It allows users to create landing pages, design email marketing campaigns, and track analytics all in one place.
Why automate lead scoring?
Lead scoring is a way to automate the process of identifying the best leads, or the ones that are most likely to convert into sales.
You can use it as an effective marketing tool to narrow down your list of prospects and determine which ones to focus on.
Lead scoring can help you save time on manual lead qualification and also ensure that your sales team only works with qualified leads.
This reduces the chances of wasting their time on prospects who don’t have a good chance of becoming customers.
Method #1: PostgreSQL CSV download
PostgreSQL steps:
You can export PostgreSQL queries as CSV and import them into Hubspot. Yes, I said CSV. This isn’t the most scalable method, but it works if done correctly. The procedure is as follows:
with score as (
select user_id,
sum(case
when event = 'email opened' then 1
when event= 'content downloaded' then 2
when event = 'webinar attended' then 3
when event = 'appointment created' then 4
else 0
end) as score_lead
from contact
group by user_id)

Once your query is executed, download the results.
Hubspot steps:
Go to your Hubspot account and click Contacts. Select your destination from the drop-down list. If you want to import the contacts, click Contacts. If you want to import a company, click Company.

Import contact example from Hubspot
Click record out of your computer as your import and click on subsequent at the lowest proper of your screen. Select one record (except you’ve got multiple) and click on subsequent again.
Select one object (except you’ve got multiple) and click on next. Click contacts as your object import and click on next.
Select File to find the CSV file you exported from PostgreSQL. Click Next. Then map the import column to the correct Hubspot property.
If there are mismatched columns, map them correctly or click on “Don’t import data in unmatched columns”.

Mapping field example from Hubspot
To go further: Set up your import files in Hubspot
Pros & Cons of Manual process
The manual process of loading data from PostgreSQL to Hubspot is not an ideal solution for most businesses.
It’s time-consuming and prone to human error, which makes it an expensive option that requires a lot of manpower.
Pros:
- Free
- Easy to implement for the small data set
Cons:
- Manual process is time-consuming
- If you have a large dataset, it will take even more time to load all of that data into HubSpot.
- Error-prone as the marketing & sales teams grow
- Data is not reliable (not automated)
Method #2: Automate with a Data Activation Platform
RestApp is a No Code Data Activation Platform that empowers anyone with an all-in-one solution to connect, model, and sync any data with his favorite tools.
Access to ready-to-use connectors to save time and pain in building them from scratch: Database, data warehouse, business apps, SFTP, GDrive…
Connect PostgreSQL and Hubspot
The steps to load data from PostgreSQL to Hubspot using RestApp are as follows:
Connect the RestApp platform to your PostgreSQL account.

Connect the RestApp platform to your Hubspot account.

You can then decide if you want to retrieve the data and/or decide to send it to Hubspot.

Load data from PostgreSQL to Hubspot
Model in No Code


In this screenshot, I have only shown two conditions to have a readable image.
Here is a preview of the results:

Automate your sync
You can activate your pipeline through a scheduler to operationalize your data automation.
In this example, the pipeline will be automatically synchronized every hour.

Pros and Cons of automating this import
Pros
- Quick set up to connect and import and let it run in the background.
- No integration required – You can start using Hubspot immediately without having to modify existing integrations or workflows.
- Add business logic within the pipeline (Lead scoring, customer health, ARPU…)
Cons:
- Free plan up to 100k rows or 30min of syncing 🙂
Which option to choose?
If you are performing a one-time task, we recommend that you use Method 1. If you want to load data from PostgreSQL to Hubspot on a regular basis, we recommend Method 2 with a Data Activation Platform.
RestApp automatically syncs PostgreSQL to Hubspot. No CSV or coding is required. Hubspot always has the latest data you and your team can trust.
In addition, Hubspot is just one of the various destinations you can sync to PostgreSQL.
If you’re interested in starting with connecting all your favorite tools, check out the RestApp website or book a demo.
Subscribe to our newsletter
Additional resources:
- [Series] Revenue Ops – How to calculate Net MRR from MongoDB to GoogleSheet? A full step-by-step guide with template
- [Series] Data teams – How to connect MongoDB to PostgreSQL: The Hard Way vs The Easy Way
- [Series] Data teams – How to connect MongoDB to MySQL: The Hard Way vs The Easy Way
- [Series] How to Build Data Pipelines in No-Code? A 6-Step guide with examples