A PayloadCMS plugin for HubSpot integration - view and manage HubSpot forms directly in your Payload admin dashboard.
- 📊 Dashboard Overview: View all your HubSpot forms with key metrics directly in your Payload admin dashboard
- 📈 Form Analytics: See comprehensive form metrics including views, submissions, conversion rates, click-through rates, and interactions
- 🔄 Auto-Sync: Forms are automatically synced with HubSpot on server startup
- 📋 Form Management: Create and manage HubSpot form connections in Payload
- 🔌 Easy Integration: Simple configuration with minimal setup required
- ⚡ Smart Caching: 1-hour cache with refresh capability for optimal performance
# npm
npm install payload-hubspot
# yarn
yarn add payload-hubspot
# pnpm
pnpm add payload-hubspotAdd the plugin to your Payload config:
import { buildConfig } from 'payload'
import { payloadHubspot } from 'payload-hubspot'
export default buildConfig({
// ... your existing config
plugins: [
payloadHubspot({
apiKey: process.env.HUBSPOT_API_KEY, // Your HubSpot API key
}),
],
})Add these to your .env file:
HUBSPOT_PORTAL_ID=your-hubspot-portal-id
HUBSPOT_API_KEY=your-hubspot-api-key
The plugin accepts the following options:
type PayloadHubspotConfig = {
apiKey?: string // Your HubSpot API key (can also be set via env var)
collections?: Partial<Record<CollectionSlug, true>> // Collections to add HubSpot fields to
disabled?: boolean // Set to true to disable the plugin functionality
disableDashboard?: boolean // Set to true to disable the dashboard component
}import { buildConfig } from 'payload'
import { payloadHubspot } from 'payload-hubspot'
export default buildConfig({
// ... your existing config
plugins: [
payloadHubspot({
apiKey: process.env.HUBSPOT_API_KEY,
collections: {
pages: true,
posts: true,
},
// Optional: disable dashboard component
disableDashboard: false,
}),
],
})The plugin adds a dashboard component to the HubSpot Forms collection that displays:
- Total number of forms
- Total form views
- Total form submissions
- Average conversion rate
- A sortable table of all forms with comprehensive metrics including:
- Form views and submissions
- Conversion rates and click-through rates
- Form interactions and submission rates
- Copy-to-clipboard functionality for form IDs
The plugin creates a hubspot-forms collection in your Payload CMS with the following fields:
formId: The HubSpot form GUID (required, unique)name: The form name (automatically synced from HubSpot, read-only)
The collection includes automatic hooks that:
- Sync form names from HubSpot when formId is updated
- Update existing forms on server startup (doesn't create new ones automatically)
The plugin adds the following API endpoints:
GET /api/hubspot/forms: Returns a list of all HubSpot forms with comprehensive statistics- Add
?refresh=trueto force a refresh of the 1-hour cache
- Add
GET /api/my-plugin-endpoint: Custom endpoint (example implementation)
Each form includes the following analytics:
views: Total form viewssubmissions: Total form submissionsconversionRate: Submissions per form view (when <= 1)clickThroughRate: Click-through rate per form viewinteractions: Total form interactionssubmissionRate: Submissions per click-throughnonContactSubmissions: Non-contact form submissions
# Clone the repository
git clone https://github.com/Brightscout/payload-hubspot.git
cd payload-hubspot
# Install dependencies
pnpm install
# Start the development server
pnpm devpnpm buildpnpm test- Node.js: ^18.20.2 || >=20.9.0
- PayloadCMS: ^3.29.0
- Package Manager: pnpm ^9 || ^10
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions: