Skip to main content

What is Marketing Events Sync?

Marketing Events Sync is a Node.js automation script that synchronizes HubSpot Marketing Events into custom CRM deal objects. The script fetches events created today from the HubSpot Marketing Events API and creates corresponding deal records with intelligent pipeline and stage mapping.

Key Features

Automatic Sync

Fetches all marketing events created today and syncs them to your custom deal object

Smart Filtering

Detects creation dates in multiple formats (milliseconds, ISO timestamps) and filters events by execution day

Duplicate Prevention

Prevents duplicates by checking both event ID and deal name before creating records

Pipeline Mapping

Maps custom properties to appropriate pipelines and deal stages automatically

How It Works

The synchronization process follows these steps:
  1. Fetch Events - Retrieves all marketing events from the HubSpot Marketing Events API with pagination support
  2. Filter by Date - Identifies events created on the current day (00:00:00 - 23:59:59 local time)
  3. Check for Duplicates - Verifies if records already exist by evento_marketing_id or dealname
  4. Extract Pipeline - Reads pipeline values from customProperties array
  5. Map Deal Stage - Assigns the appropriate deal stage based on pipeline mapping
  6. Create Deal Record - Creates a new deal with all event metadata

Use Cases

Automatically create deals when new marketing events are scheduled, ensuring your sales team has visibility into all upcoming events.
Track events across different business units or product lines with automatic pipeline and stage assignment based on event properties.
Sync events from SimpleEvents.io (or similar platforms) that create HubSpot marketing events, maintaining custom properties like location and configuration.

Data Mapping

The script maps marketing event fields to deal properties:
Marketing Event FieldDeal PropertyDescription
eventNamedealnameEvent title
startDateTimefecha_hora_de_inicioEvent start date/time
endDateTimefecha_hora_finEvent end date/time
eventOrganizerorganizador_eventoMapped to valid options (Icare, G12, Legal)
eventDescriptiondescriptionEvent description
eventUrlurl_eventoEvent registration or info URL
objectIdevento_marketing_idUnique event identifier
eventTypetipo_de_evento_de_marketingEvent type (Webinar, Conference, etc.)
customProperties.pipelinepipelinePipeline ID extracted from custom properties
Auto-calculateddealstageDeal stage based on pipeline mapping

System Requirements

Ensure your environment meets these requirements before running the script.
  • Node.js: Version 16 or higher (requires fetch API support)
  • HubSpot Account: Professional or Enterprise tier with Marketing Hub
  • API Access: Private app or OAuth token with the following scopes:
    • crm.objects.marketing_events.read
    • crm.objects.deals.read
    • crm.objects.deals.write
  • Custom Object: Deal object configured with the required custom properties listed above

Security Considerations

The access token is currently stored in cleartext in events.js. Do not commit tokens to public repositories.
Before deploying to production:
  1. Move the access token to an environment variable
  2. Use HubSpot private apps with minimal required scopes
  3. Implement token rotation policies
  4. Add request logging for audit trails

Next Steps

Get Started

Follow the quickstart guide to set up and run your first sync

Build docs developers (and LLMs) love