Intermediate~20 min setupCRM & EmailVerified April 2026
HubSpot logo
Gmail logo

How to Log Gmail Activity to HubSpot CRM with N8n

Automatically log sent and received Gmail emails to HubSpot contact timelines when they match existing CRM contacts.

Steps and UI details are based on platform versions at time of writing — check each platform for the latest interface.

HubSpot Gmail extension exists as a native integration, but it requires manual setup per user and doesn't create contacts automatically. This guide uses an automation platform for full control. View native option →

Best for

Teams that need custom email filtering, handle 200+ emails daily, or want to parse email content for lead intelligence.

Not ideal for

HubSpot Sales Hub Professional users who can use native Gmail integration or teams wanting zero-code setup.

Sync type

polling

Use case type

sync

Real-World Example

💡

A 25-person B2B consulting firm uses this to automatically log client emails to HubSpot deal records, but only emails containing 'proposal' or 'contract' in the subject. Before automation, account managers manually copied important emails to CRM, missing 40% of client communications. Now every proposal discussion appears on the deal timeline within 5 minutes.

What Will This Cost?

Drag the slider to your expected monthly volume.

/mo
505005K50K

Each platform counts differently — Zapier: 1 task per trigger. Make: 1 operation per module per record. n8n: 1 execution per run.

Prices shown for annual billing. Based on published pricing as of April 2026.

Estimated ROI

1000

min saved/mo

$583

labor value/mo

Free

no platform cost

Based on ~2 min manual effort per operation at $35/hr fully loaded labor cost.

Implementation

Skip the setup

Import this workflow directly into n8n

Copy the pre-built n8n blueprint and paste it straight into n8n. All modules, filters, and field mappings are already configured — you just need to connect your accounts.

Before You Start

Make sure you have everything ready.

HubSpot account with Marketing Hub Starter or higher (timeline events API access)
Gmail account with API access enabled in Google Cloud Console
Google Cloud project with Gmail API and credentials configured
N8n instance running (cloud or self-hosted)
Custom timeline event type created in HubSpot for email logging

Field Mapping

Map these fields between your apps.

FieldAPI Name
Required
Email Subjectsubject
Email Body Previewsnippet
Sender Emailfrom[0].email
Email TimestampinternalDate
3 optional fields▸ show
Message IDid
Thread IDthreadId
Email DirectionlabelIds

Step-by-Step Setup

1

Dashboard > New Workflow

Create New N8n Workflow

Start a blank workflow in N8n. This will be a polling workflow that checks for new emails and logs them to HubSpot.

  1. 1Click 'New Workflow' from the N8n dashboard
  2. 2Name it 'Gmail to HubSpot Email Logger'
  3. 3Click 'Save' to create the empty workflow
What you should see: You should see a blank canvas with a '+' button to add your first node.
2

Add Node > Gmail > Get Messages

Add Gmail Trigger Node

Set up the Gmail node to watch for new emails. This will poll Gmail every 5 minutes for messages sent or received.

  1. 1Click the '+' button and search for 'Gmail'
  2. 2Select the Gmail node from the results
  3. 3Choose 'Get Messages' as the operation
  4. 4Set Query to 'is:sent OR is:unread' to capture sent and received emails
What you should see: The Gmail node appears with connection status 'Not connected' in orange.
Common mistake — Don't use the Gmail Trigger node - it's unreliable. Use Get Messages with Schedule Trigger instead.
n8n
+
click +
search apps
HubSpot
HU
HubSpot
Add Gmail Trigger Node
HubSpot
HU
module added
3

Gmail Node > Credentials > Create New

Connect Gmail Account

Authenticate your Gmail account with N8n. You'll need Gmail API access enabled in Google Cloud Console.

  1. 1Click 'Create New' next to Gmail credentials
  2. 2Select 'OAuth2 API' authentication method
  3. 3Enter your Google Client ID and Client Secret
  4. 4Click 'Connect my account' and complete OAuth flow
What you should see: Green 'Connected' badge appears next to the Gmail node.
Common mistake — Enable Gmail API in Google Cloud Console first - the connection will fail without it.
n8n settings
Connection
Choose a connection…Add
click Add
HubSpot
Log in to authorize
Authorize n8n
popup window
Connected
green checkmark
4

Add Node > Schedule Trigger

Add Schedule Trigger

Connect a Schedule Trigger before Gmail to poll for new emails every 5 minutes. This ensures the workflow runs automatically.

  1. 1Click '+' before the Gmail node
  2. 2Search for and select 'Schedule Trigger'
  3. 3Set Trigger Interval to 'Every 5 minutes'
  4. 4Connect the Schedule output to Gmail input
What you should see: Schedule Trigger connects to Gmail with a gray arrow line between nodes.
Common mistake — Don't set interval below 2 minutes - Gmail API has rate limits that will cause failures.
5

Add Node > IF

Filter for Contact Emails

Add an IF node to only process emails from addresses that exist in HubSpot. This prevents logging irrelevant emails.

  1. 1Add an IF node after Gmail
  2. 2Set condition to check if sender email exists
  3. 3Use expression: {{ $json.from[0].email }}
  4. 4Connect to next step only on 'true' branch
What you should see: IF node shows with True/False output branches ready for connections.
Common mistake — Test the email field path first - Gmail API structure varies between sent/received messages.
HubSpot
HU
trigger
filter
Condition
matches criteria?
yes — passes through
no — skipped
Gmail
GM
notified
6

Add Node > HubSpot > Get Contact by Email

Add HubSpot Contact Search

Search HubSpot to verify the email sender exists as a contact before logging the email activity.

  1. 1Add HubSpot node after IF (true branch)
  2. 2Select 'Get Contact by Email' operation
  3. 3Map Email field to Gmail sender: {{ $node['Gmail'].json.from[0].email }}
  4. 4Set 'Continue on Fail' to true
What you should see: HubSpot node configured to search contacts by email address.
7

HubSpot Node > Credentials > Create New

Connect HubSpot Account

Authenticate with HubSpot using your API key. You need at least Marketing Hub Starter for timeline events API access.

  1. 1Click 'Create New' next to HubSpot credentials
  2. 2Select 'API Key' authentication
  3. 3Paste your HubSpot API key from Settings > Integrations
  4. 4Click 'Save' to test connection
What you should see: Green connection badge appears on HubSpot node.
Common mistake — Free HubSpot accounts can't write timeline events - you'll get 402 payment required errors.
8

Add Node > IF

Add Second IF for Contact Check

Check if the contact search returned results before attempting to log the email. This prevents errors when emailing non-contacts.

  1. 1Add another IF node after HubSpot contact search
  2. 2Set condition: {{ $json.id !== undefined }}
  3. 3This checks if contact ID exists in the response
  4. 4Connect true branch to next step
What you should see: Second IF node ready to filter out non-contact emails.
Common mistake — Use !== undefined, not just checking truthiness - HubSpot returns id: 0 for some contacts.
9

Add Node > HubSpot > Create Timeline Event

Create Timeline Event

Add another HubSpot node to create the email timeline event on the contact record with email details.

  1. 1Add new HubSpot node after second IF (true branch)
  2. 2Select 'Create Timeline Event' operation
  3. 3Set Event Type ID to email event type
  4. 4Map Object ID to contact ID from previous step
What you should see: Timeline event node configured to log emails to contact records.
Common mistake — You must create a custom timeline event type in HubSpot first - default email events are protected.
10

HubSpot Timeline Node > Properties

Map Email Data Fields

Configure the timeline event properties with email subject, body preview, and timestamp from Gmail.

  1. 1In Properties section, click 'Add Property'
  2. 2Map 'subject' to {{ $node['Gmail'].json.subject }}
  3. 3Map 'email_body' to {{ $node['Gmail'].json.snippet }}
  4. 4Map 'timestamp' to {{ $node['Gmail'].json.internalDate }}
What you should see: Properties section shows 3 mapped fields with Gmail data expressions.
Common mistake — Use snippet not body - full email body often exceeds HubSpot's 65k character limit.
HubSpot fields
firstname
lastname
email
company
hs_lead_status
available as variables:
1.props.firstname
1.props.lastname
1.props.email
1.props.company
1.props.hs_lead_status
11

Toolbar > Test Workflow

Test the Workflow

Run a test execution to verify emails are found in Gmail and logged to the correct HubSpot contact.

  1. 1Click 'Test workflow' button in top toolbar
  2. 2Check each node for green success indicators
  3. 3Verify timeline event appears in HubSpot contact record
  4. 4Check execution logs for any errors
What you should see: All nodes show green checkmarks and timeline event appears in HubSpot.
Common mistake — Test with a real email to an existing contact - sample data won't trigger the full flow correctly.
n8n
▶ Run once
executed
HubSpot
Gmail
Gmail
🔔 notification
received
12

Workflow > Active Toggle

Activate Workflow

Turn on the workflow to start automatically logging emails every 5 minutes. Monitor the first few runs for issues.

  1. 1Click the toggle switch in top right to 'Active'
  2. 2Confirm activation in the popup dialog
  3. 3Check Executions tab after 10 minutes for first run
  4. 4Verify no error notifications appear
What you should see: Toggle shows 'Active' and first scheduled execution appears in logs.

Drop this into an n8n Code node.

JavaScript — Code Node// Extract meeting times from email body
▸ Show code
// Extract meeting times from email body
const emailBody = $node['Gmail'].json.snippet;
const timeRegex = /(\d{1,2}:\d{2}\s?(AM|PM|am|pm))/g;

... expand to see full code

// Extract meeting times from email body
const emailBody = $node['Gmail'].json.snippet;
const timeRegex = /(\d{1,2}:\d{2}\s?(AM|PM|am|pm))/g;
const meetingTimes = emailBody.match(timeRegex);

return [{
  json: {
    ...items[0].json,
    meeting_time_detected: meetingTimes ? meetingTimes[0] : null,
    contains_meeting: meetingTimes !== null
  }
}];

Scaling Beyond 300+ emails/day+ Records

If your volume exceeds 300+ emails/day records, apply these adjustments.

1

Switch to Webhook Trigger

Replace polling with Gmail Push API webhooks to get real-time email notifications. Set up Cloud Pub/Sub topic in Google Cloud and configure Gmail to push new message events directly to N8n.

2

Batch Timeline Events

Group multiple emails into single HubSpot API calls using the batch timeline endpoint. Process up to 100 timeline events per request instead of individual calls for each email.

3

Add Redis Caching

Cache HubSpot contact lookups in Redis to avoid repeated API calls for the same email addresses. Set 24-hour TTL to balance freshness with API quota savings.

Going live

Production Checklist

Before you turn this on for real, confirm each item.

Troubleshooting

Common errors and how to fix them.

Frequently Asked Questions

Common questions about this workflow.

Analysis

VerdictWhy n8n for this workflow

Use N8n for this if you need custom email filtering logic or handle high email volumes (500+ per day). The code nodes let you parse email headers, detect signatures, or extract meeting times that Zapier can't handle. You also get unlimited executions on self-hosted N8n. Skip N8n if you just want basic email logging with zero setup - HubSpot's native Gmail integration does this automatically for Sales Hub Professional users.

Cost

This workflow uses 4 executions per email logged (schedule trigger, Gmail fetch, contact search, timeline creation). At 200 emails/month, that's 800 executions total. N8n cloud starts at $20/month for 5,000 executions, so you have plenty of headroom. Make would cost $29/month for the same operations. Zapier charges $30/month for their Professional plan to handle the multi-step logic. N8n cloud is cheapest here by $9/month.

Tradeoffs

Make has better built-in Gmail parsing - it automatically splits sender name from email address and handles thread detection. Zapier offers a pre-built HubSpot email logging template that works in 3 clicks. But N8n wins on customization - you can add lead scoring based on email content, detect out-of-office replies, or route different email types to different HubSpot properties. The code flexibility matters more than convenience once you want email intelligence.

HubSpot's timeline events API is picky about data types - send numbers as strings or they'll reject. Gmail's internalDate comes as epoch milliseconds but HubSpot wants ISO format, so add a date conversion node. The Gmail API paginates at 100 messages, but most polling intervals won't hit that limit. Watch for OAuth token expires every 7 days - N8n cloud handles refresh automatically but self-hosted needs manual token management.

Ideas for what to build next

  • Add Email Sentiment AnalysisConnect a sentiment analysis API to score email tone and add positive/negative flags to HubSpot timeline events for sales context.
  • Create Deal Stage TriggersSet up additional workflows that trigger specific email templates when HubSpot deals change stages, creating two-way email automation.
  • Build Email Response TrackingExtend the workflow to track email open rates and responses by parsing Gmail thread conversations and updating HubSpot engagement scores.

Related guides

Was this guide helpful?
HubSpot + Gmail overviewn8n profile →