Skip to main content

Automated HubSpot Marketing Events Sync

Synchronize HubSpot Marketing Events to custom CRM objects with intelligent filtering, duplicate prevention, and automated pipeline mapping.

Quick Start

Get your Marketing Events sync running in minutes

1

Set up authentication

Configure your HubSpot Private App access token in the script or as an environment variable.
PowerShell
$env:HUBSPOT_PAT = "pat-na1-..."
Never commit access tokens to public repositories. Always use environment variables in production.
2

Configure the sync script

Update the accessToken and custom object API endpoint in events.js to match your HubSpot account setup.
events.js
const accessToken = process.env.HUBSPOT_PAT;
const CUSTOM_OBJECT_API = "https://api.hubapi.com/crm/v3/objects/deals";
3

Run the sync

Execute the test script to sync today’s Marketing Events to your custom CRM object.
node test.js
📍 Página obtenida: 100 eventos encontrados
✅ Total de eventos obtenidos: 250
📅 Eventos encontrados hoy: 5
✅ Evento creado: Test Event
4

Review sync results

The callback returns detailed metrics including totalEvents, todayEvents, createdCount, skippedCount, and failedCount. Use this data to monitor sync performance.

Key Features

Built for reliability and efficiency

Intelligent Date Filtering

Automatically detects creation dates in multiple formats (milliseconds, ISO timestamps) and filters events for the current day.

Duplicate Prevention

Checks for existing records by both ID and name to prevent validation errors and duplicate entries.

Pipeline Mapping

Maps custom pipeline values to corresponding deal stages based on configurable mappings.

Organizer Normalization

Converts organizer names to valid HubSpot options automatically.

Paginated Fetching

Handles large event datasets with automatic pagination through the Marketing Events API.

Comprehensive Logging

Detailed console output for monitoring sync progress and debugging issues.

Explore by Topic

Deep dive into specific aspects of the sync system

How It Works

Understand the sync workflow from API fetch to record creation.

Authentication

Set up secure access to the HubSpot API.

Functions Reference

Explore all exported functions and their signatures.

API Endpoints

HubSpot API endpoints used by the sync script.

Local Setup

Run and test the sync script on your local machine.

Troubleshooting

Common issues and how to resolve them.

Ready to automate your event sync?

Follow our quickstart guide to get your Marketing Events syncing to HubSpot CRM in minutes.

Start Syncing Now

Build docs developers (and LLMs) love