PHPackages                             humanmade/hubspot-form-block - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. humanmade/hubspot-form-block

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

humanmade/hubspot-form-block
============================

Hubspot Form Embed Block for WordPress

0.7.0(1mo ago)26.4k↑295.2%3[1 PRs](https://github.com/humanmade/hubspot-form-block/pulls)gpl-2.0-or-laterJavaScriptCI passing

Since Aug 1Pushed 3w ago8 watchersCompare

[ Source](https://github.com/humanmade/hubspot-form-block)[ Packagist](https://packagist.org/packages/humanmade/hubspot-form-block)[ RSS](/packages/humanmade-hubspot-form-block/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (3)Versions (25)Used By (0)

HubSpot Form Block
==================

[](#hubspot-form-block)

A WordPress block plugin that embeds HubSpot Forms v4 directly in page content. Forms render inline (not iframed) — HubSpot injects DOM into the container element.

Features
--------

[](#features)

- **HubSpot Forms v4 API** — uses the modern developer embed API
- **Inline success message** — add any WordPress blocks as the post-submission message; shown in place of the form after submission
- **Gated content** — optionally remember submissions in the browser (per page URL) and show the success content immediately on return visits, hiding the form permanently; supports a "First Submission Message" block for content only shown at the moment of first submission
- **Global settings** — set Portal ID and region site-wide; override per block instance
- **Google Tag Manager** — fires a configurable dataLayer event on submission (default: `hubspot_form_submit`)
- **Deferred script loading** — HubSpot tracking JS loaded asynchronously in the footer
- **Custom submit button text** — override the form's submit button label per block instance
- **Redirect on submit** — optionally redirect to a URL instead of showing an inline message
- **Multiple instances** — multiple instances of the same form on a single page are fully supported

Block settings
--------------

[](#block-settings)

SettingDescriptionPortal IDHubSpot portal ID. Can be set as a global default and overridden per block.Region`eu1` (Europe) or `na1` (North America). Can be set as a global default.Form IDHubSpot form ID.Redirect URLRedirect to this URL after submission. Overrides the inline message if set.Submit button textOverride the form's submit button label.GTM event namedataLayer event name pushed on submission. Defaults to `hubspot_form_submit`.Success message (inner blocks)WordPress blocks shown in place of the form after successful submission. Not shown if a redirect URL is set.Enable gated contentWhen on, the browser remembers that this form has been submitted on this page (stored in `localStorage`). Returning visitors see the success message immediately instead of the form. Use the "Insert First Submission Message" button to add a block whose content is only shown at the moment of the first submission — stripped on subsequent visits. Disabled when a redirect URL is set.Global settings
---------------

[](#global-settings)

Portal ID and region can be set globally via **Settings → General** in the WordPress admin (or via the REST API at `/wp-json/wp/v2/settings`). Individual block instances can override these values. Admins can promote per-block values to global defaults using the "Set as global defaults" button in the block sidebar.

Styling forms
-------------

[](#styling-forms)

Forms can be styled from within the HubSpot dashboard, or by overriding the CSS variables documented here:

Installation
------------

[](#installation)

1. Download `hubspot-form-block.zip` from the [latest release](https://github.com/humanmade/hubspot-form-block/releases/latest).
2. Upload and activate via **Plugins → Add New → Upload Plugin** in the WordPress admin.
3. Set your Portal ID and region under **Settings → General**.
4. Insert the **HubSpot Form** block and enter your Form ID.

Developer workflow
------------------

[](#developer-workflow)

```
npm install
npm run start           # Watch mode — compiles src/ to build/
npm run build           # Production build
npm run playground:start  # Start local WordPress via Playground on :9400
npm run test:e2e        # Run Playwright E2E tests (starts Playground automatically)
npm run test:e2e:debug  # Playwright debug mode
npm run test:e2e:watch  # Playwright UI mode
npm run lint:js         # Lint JS
npm run lint:css        # Lint CSS
```

> **Note:** The `--webpack-copy-php` flag on `build`/`start` is required — it copies `render.php` from `src/` to `build/`. Do not remove it.

Architecture
------------

[](#architecture)

```
src/
├── block.json          # Block registration, attributes, supports
├── index.js            # Block registration entry
├── edit.js             # Block editor UI (InspectorControls + inner blocks)
├── save.js             # Saves inner block content
├── view.js             # Frontend JS: form events, success message, GTM
├── render.php          # Server render: form container +  for success message
├── editor.scss         # Editor-only styles
└── style.scss          # Frontend + editor styles
hubspot-form-block.php  # Plugin entry: block registration, script enqueue, settings API

```

**Config injection:** Each form instance gets a unique target ID (`hubspot-form-{formId}-{n}`). A `` block writes `window.hsForms[target] = {...config}` so `view.js` can pick it up when HubSpot fires `hs-form-event:on-ready`.

**Success message:** When inner blocks are present and no redirect URL is set, `render.php` emits a `` containing the server-rendered block HTML. On `hs-form-event:on-submission:success`, `view.js` clones the template content into the form container, replacing the form with the success message.

**Gated content (`persistSuccess`):** When enabled, `view.js` writes the current `window.location.pathname` into a `localStorage` entry keyed `hs-form-submitted:{formId}` (value is a JSON array of paths, so the same form on different URLs is tracked independently). A synchronous inline `` emitted by `render.php` checks this array on page load and pre-swaps the container before paint if the current path is present, preventing HubSpot from rendering the form at all. Any inner `core/group` block with class `is-hubspot-form-first-submission` (the "First Submission Message" variation) is stripped from the clone during pre-swap but preserved for the fresh-submission path.

Release workflow
----------------

[](#release-workflow)

1. Push to `main` → `build-and-release.yml` automatically merges built `build/` into the `release` branch.
2. Create a GitHub Release with a semver tag → `release.yml` replaces the `__VERSION__` placeholder in `hubspot-form-block.php`, commits, retags, and uploads `hubspot-form-block.zip`.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance93

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~20 days

Total

12

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77dbeefb7745010589603f2ffc6ff310d8f700b58e08d52af190744c43342526?d=identicon)[roborourke](/maintainers/roborourke)

---

Top Contributors

[![roborourke](https://avatars.githubusercontent.com/u/23417?v=4)](https://github.com/roborourke "roborourke (45 commits)")[![sambulance](https://avatars.githubusercontent.com/u/5014023?v=4)](https://github.com/sambulance "sambulance (7 commits)")[![maugelves](https://avatars.githubusercontent.com/u/2919706?v=4)](https://github.com/maugelves "maugelves (2 commits)")[![mattheu](https://avatars.githubusercontent.com/u/494927?v=4)](https://github.com/mattheu "mattheu (1 commits)")

### Embed Badge

![Health badge](/badges/humanmade-hubspot-form-block/health.svg)

```
[![Health](https://phpackages.com/badges/humanmade-hubspot-form-block/health.svg)](https://phpackages.com/packages/humanmade-hubspot-form-block)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[mediawiki/maps

Adds various mapping features to MediaWiki

84152.3k3](/packages/mediawiki-maps)[starcitizentools/citizen-skin

A beautiful, usable, responsive MediaWiki skin with in-depth extension support. Originally developed for the Star Citizen Wiki.

3376.6k](/packages/starcitizentools-citizen-skin)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19251.4k3](/packages/civicrm-civicrm-drupal-8)[altis/core

Core module for Altis

19228.0k3](/packages/altis-core)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5721.7k4](/packages/pfefferle-wordpress-activitypub)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
