Skip to content

Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.

feat(conversion-tracking): add HubSpot Forms detection

Aaron Beashel2fcf94ff1f47
diff --git a/VERSIONS.md b/VERSIONS.md
index c80d9f3..76ea48f 100644
--- a/VERSIONS.md
+++ b/VERSIONS.md
@@ -63,7 +63,7 @@ Current versions of all skills. Agents can compare against local versions to che
- Added the **`conversion-tracking`** skill (1.0.0). Setting up, auditing, verifying and fixing the path from a conversion on a website to Google Ads, Meta, GA4, LinkedIn, TikTok and Microsoft Ads, for lead generation and ecommerce. Gives an orphaned job a home. Analytics listed conversion tracking as a trigger without covering it, attribution routed pixels and CAPI to ads, and ads held one reference file. Built on one distinction, that lead gen has to infer success from a browser signal while ecommerce reads it from an order record. Nine references (how each form, booking and chat tool signals success, the complete browser-side path, the server-side options with prices, ecommerce platforms including Shopify's 26 Aug 2026 Additional Scripts removal, Google Ads, Meta, other platforms, the audit playbook, and why the numbers never match), 22 detection snippets, importable GTM recipes merged by `scripts/build_recipe.py`, and 16 evals. Audit scoring follows the ads skill's audit guardrails, summarised inline. New skill = repo y release; total skills: 51. Contributed by Aaron Beashel (Converly ◆, a Verified Partner) and reviewed against the repo's partner-integrity bar before merge:
- **Neutrality:** free and native paths first (browser Enhanced Conversions, Meta advanced matching, Google tag gateway, Meta CAPI Gateway, tool webhooks); a "when server-side matters less" section; the partner row matches the others in length and lists its tradeoffs; a free-tier row in the side-by-side; paid options surface at the delivery decision, not in every answer; the contributor's other tool (Attributer) is disclosed with alternatives; five neutrality evals (ids 17–21) and one delivery-decision eval (id 22).
- **Facts:** browser tags can send hashed email and phone; Meta dropped the AEM 8-event cap in May 2023; Microsoft has a Conversions API (self-serve token, still rolling out); LinkedIn dedup needs a shared `eventId`; Meta CAPI for CRM gates; Google tROAS vs tCPA minimums; conversion-adjustment windows; Shopify's 1 Oct 2026 script-tag change; the undercount stated as a 10–30% range rather than a universal 30%.
- - **Assets:** 18 detection snippets replaced with listeners that passed live checks on real forms, Jotform's now firing on the completion message its iframe and script embeds send, and Framer's confirming through Framer's own form request; every GTM recipe uses Tag Manager's import format, so Import Container accepts it; 10 drifted GTM recipes regenerated from their snippets, with `scripts/check_recipes.py` to keep them in sync; `build_recipe.py` validates every ID and substitutes safely (no JSON or JS injection) on Python 3.8+; every send tag requires consent (the Google Ads conversion tag `ad_storage` only); snippet success-signal types documented; three new tested detectors (Squarespace Forms, Cal.com and Acuity Scheduling), for 25 in all.
+ - **Assets:** 18 detection snippets replaced with listeners that passed live checks on real forms, Jotform's now firing on the completion message its iframe and script embeds send, and Framer's confirming through Framer's own form request; every GTM recipe uses Tag Manager's import format, so Import Container accepts it; 10 drifted GTM recipes regenerated from their snippets, with `scripts/check_recipes.py` to keep them in sync; `build_recipe.py` validates every ID and substitutes safely (no JSON or JS injection) on Python 3.8+; every send tag requires consent (the Google Ads conversion tag `ad_storage` only); snippet success-signal types documented; four new tested detectors (Squarespace Forms, HubSpot Forms, Cal.com and Acuity Scheduling), for 26 in all.
- **Repo fit:** operative rules in the description, a revops boundary, no cross-skill relative links, two audit checks restored from the retired ads reference.
- **Converly integration guide** filled in (capabilities, setup, operations); platform lift stats carry a holdout caveat.
- **analytics** (2.0.1 → 2.0.2): description drops the "conversion tracking" and "track conversions" triggers and hands getting conversions into ad platforms to conversion-tracking.
diff --git a/skills/conversion-tracking/SKILL.md b/skills/conversion-tracking/SKILL.md
index e42527a..cea0974 100644
--- a/skills/conversion-tracking/SKILL.md
+++ b/skills/conversion-tracking/SKILL.md
@@ -157,7 +157,7 @@ Load a reference when the task reaches it. Nothing here is optional reading, it'
| The audit's evidence procedure, scoring, and report template | `references/audit-playbook.md` |
| Why the numbers never match, loss magnitudes, and the refund asymmetry | `references/discrepancies.md` |
-Assets: [`assets/snippets/`](assets/snippets/README.md) holds paste-in success detectors for 21 lead-gen tools, plus four universal patterns for the moments no form tool owns: phone call clicks (the most under-tracked conversion in local services), file downloads, thank-you page arrivals, and a generic AJAX success pattern. [`assets/gtm-recipes/`](assets/gtm-recipes/README.md) holds the importable GTM containers (detection and send, with event names in [`event-map.json`](assets/gtm-recipes/event-map.json)), and `scripts/build_recipe.py` merges them with the user's IDs into one import file.
+Assets: [`assets/snippets/`](assets/snippets/README.md) holds paste-in success detectors for 22 lead-gen tools, plus four universal patterns for the moments no form tool owns: phone call clicks (the most under-tracked conversion in local services), file downloads, thank-you page arrivals, and a generic AJAX success pattern. [`assets/gtm-recipes/`](assets/gtm-recipes/README.md) holds the importable GTM containers (detection and send, with event names in [`event-map.json`](assets/gtm-recipes/event-map.json)), and `scripts/build_recipe.py` merges them with the user's IDs into one import file.
## Boundaries
diff --git a/skills/conversion-tracking/assets/gtm-recipes/README.md b/skills/conversion-tracking/assets/gtm-recipes/README.md
index 87f9890..6ed8ad5 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/README.md
+++ b/skills/conversion-tracking/assets/gtm-recipes/README.md
@@ -1,10 +1,10 @@
# GTM recipes
-Importable Google Tag Manager containers that produce one import-ready file per tool and destination, no manual tag building (25 detectors x 6 destinations).
+Importable Google Tag Manager containers that produce one import-ready file per tool and destination, no manual tag building (26 detectors x 6 destinations).
## The 2 layers
-**`detect/` (25 recipes, ready to import as-is).** Each contains a listener tag that detects one tool's conversion moment (form submitted, meeting booked) and pushes a canonical dataLayer event, plus a custom event trigger on that event and dataLayer variables for the form or booking ID. The event names are listed in `../snippets/README.md` and in `event-map.json`.
+**`detect/` (26 recipes, ready to import as-is).** Each contains a listener tag that detects one tool's conversion moment (form submitted, meeting booked) and pushes a canonical dataLayer event, plus a custom event trigger on that event and dataLayer variables for the form or booking ID. The event names are listed in `../snippets/README.md` and in `event-map.json`.
**`send/` (6 templates, need values filled in before import).** Each contains the tag that actually records the conversion, wired to a placeholder trigger:
diff --git a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-hubspot-forms.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-hubspot-forms.json
new file mode 100644
index 0000000..a69aec5
--- /dev/null
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-hubspot-forms.json
@@ -0,0 +1,103 @@
+{
+ "exportFormatVersion": 2,
+ "exportTime": "2026-09-24 00:00:00",
+ "containerVersion": {
+ "path": "accounts/0/containers/0/versions/0",
+ "accountId": "0",
+ "containerId": "0",
+ "containerVersionId": "0",
+ "container": {
+ "path": "accounts/0/containers/0",
+ "accountId": "0",
+ "containerId": "0",
+ "name": "Conversion Detection - HubSpot Forms",
+ "publicId": "GTM-XXXXXXX",
+ "usageContext": [
+ "WEB"
+ ],
+ "fingerprint": "0",
+ "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/0/containers/0/workspaces/0"
+ },
+ "tag": [
+ {
+ "accountId": "0",
+ "containerId": "0",
+ "tagId": "1",
+ "name": "Conversion Detection - HubSpot Forms Submission Listener",
+ "type": "html",
+ "parameter": [
+ {
+ "type": "TEMPLATE",
+ "key": "html",
+ "value": "<script>\n(function () {\n if (window.__ctDetectHubspotForms) return;\n window.__ctDetectHubspotForms = true;\n window.dataLayer = window.dataLayer || [];\n\n // Updated-editor conversions are keyed by HubSpot's documented conversion\n // ID. Legacy messages use event-object identity because their documented\n // callback payload has no conversion ID.\n var seenConversions = {};\n var seenLegacyEvents = typeof WeakSet === 'function' ? new WeakSet() : [];\n\n function fireConversion(formId, conversionId, acceptedContext) {\n var id = formId ? String(formId) : '';\n if (typeof conversionId !== 'string' || !conversionId) return false;\n var key = '$' + conversionId;\n if (seenConversions[key]) return false;\n seenConversions[key] = true;\n var handled = false;\n var adapter = window.__ctHubspotMethod2Handler;\n if (typeof adapter === 'function') {\n try {\n handled = adapter({\n formId: id,\n instanceId: acceptedContext && acceptedContext.instanceId || '',\n conversionId: conversionId,\n form: acceptedContext && acceptedContext.form || null\n }) === true;\n } catch (e) {\n handled = false;\n }\n }\n if (!handled) window.dataLayer.push({ event: 'hubspot_form_submitted', form_id: id });\n return true;\n }\n\n function claimLegacyEvent(event) {\n if (!event || typeof event !== 'object') return false;\n if (seenLegacyEvents && typeof seenLegacyEvents.has === 'function') {\n if (seenLegacyEvents.has(event)) return false;\n seenLegacyEvents.add(event);\n return true;\n }\n if (seenLegacyEvents.indexOf(event) !== -1) return false;\n seenLegacyEvents.push(event);\n return true;\n }\n\n // ------------------------------------------------------------\n // Path 1: current forms editor (live-verified)\n // ------------------------------------------------------------\n // HubSpot dispatches this on the .hs-form-frame container and lets it bubble\n // (or on document itself when it cannot find the container), with\n // detail = { formId, instanceId }. It only ever follows a submission\n // HubSpot's server accepted. Listening on document in the capture phase\n // catches both dispatch points and cannot be silenced by page code that\n // stops the event's propagation further down.\n function hubspotFormsApi() {\n return window.HubSpotFormsV4 || window.HubspotFormsV4 || null;\n }\n\n function handleSubmissionSuccess(event) {\n try {\n var detail = event && event.detail;\n if (!detail || typeof detail.formId !== 'string' || !detail.formId) return;\n if (typeof detail.instanceId !== 'string' || !detail.instanceId) return;\n // When HubSpot's forms API is on the page, the event must name a form\n // instance HubSpot actually rendered here. A stray or malformed event\n // with a made-up instance id is ignored.\n var api = hubspotFormsApi();\n if (!api || typeof api.getFormFromEvent !== 'function') return;\n var form = api.getFormFromEvent(event);\n if (!form || typeof form.getFormId !== 'function' ||\n typeof form.getInstanceId !== 'function' ||\n typeof form.getConversionId !== 'function') return;\n if (form.getFormId() !== detail.formId ||\n form.getInstanceId() !== detail.instanceId) return;\n // HubSpot documents getConversionId as valid after successful\n // submission. It is the stable key for event replay and repeated submits.\n fireConversion(detail.formId, form.getConversionId(), { form: form, instanceId: detail.instanceId });\n } catch (e) {\n // Never throw back into HubSpot's own event dispatch.\n }\n }\n\n // ------------------------------------------------------------\n // Path 2: legacy forms editor (ported from the production module)\n // ------------------------------------------------------------\n // Legacy forms announce each lifecycle step with a postMessage of\n // { type: 'hsFormCallback', eventName, id, data }. Only 'onFormSubmitted'\n // means the submission was accepted; 'onFormSubmit' also fires for\n // submissions that then fail validation, so it is ignored.\n //\n // The legacy callback payload documents its form ID but not a safe mapping\n // from a cross-origin source WindowProxy to that ID. Accept only the inline\n // same-window callback; cross-origin iframe messages fail closed until a\n // vendor-supported source/form binding can be verified.\n function isTrustedOrigin(event) {\n return !!(event && event.source === window &&\n event.origin === window.location.origin);\n }\n\n function handleMessage(event) {\n try {\n // Reject an unbound source before even reading its structured-clone data.\n if (!isTrustedOrigin(event)) return;\n var data = event && event.data;\n if (!data || typeof data !== 'object') return;\n if (data.type !== 'hsFormCallback') return;\n if (data.eventName !== 'onFormSubmitted') return;\n var formId = data.id;\n if (typeof formId !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(formId)) return;\n if (!claimLegacyEvent(event)) return;\n // The documented legacy callback runs after persistence, but has no\n // stable conversion ID. The local guard only recognizes replay of this\n // exact MessageEvent object; a distinct event object may be a replay or a\n // new conversion, so cross-event deduplication is not claimed.\n var handled = false;\n var adapter = window.__ctHubspotMethod2Handler;\n if (typeof adapter === 'function') {\n try {\n handled = adapter({ formId: formId, legacyEvent: event }) === true;\n } catch (e) { handled = false; }\n }\n if (!handled) window.dataLayer.push({ event: 'hubspot_form_submitted', form_id: formId });\n } catch (e) {\n // Never throw back into the page's own message handling.\n }\n }\n\n document.addEventListener('hs-form-event:on-submission:success', handleSubmissionSuccess, true);\n window.addEventListener('message', handleMessage, false);\n})();\n</script>"
+ },
+ {
+ "type": "BOOLEAN",
+ "key": "supportDocumentWrite",
+ "value": "false"
+ }
+ ],
+ "firingTriggerId": [
+ "2147479553"
+ ],
+ "tagFiringOption": "ONCE_PER_EVENT",
+ "monitoringMetadata": {
+ "type": "MAP"
+ },
+ "consentSettings": {
+ "consentStatus": "NOT_SET"
+ }
+ }
+ ],
+ "trigger": [
+ {
+ "accountId": "0",
+ "containerId": "0",
+ "triggerId": "2",
+ "name": "CE - HubSpot Form Submitted",
+ "type": "CUSTOM_EVENT",
+ "customEventFilter": [
+ {
+ "type": "EQUALS",
+ "parameter": [
+ {
+ "type": "TEMPLATE",
+ "key": "arg0",
+ "value": "{{_event}}"
+ },
+ {
+ "type": "TEMPLATE",
+ "key": "arg1",
+ "value": "hubspot_form_submitted"
+ }
+ ]
+ }
+ ],
+ "filter": []
+ }
+ ],
+ "variable": [
+ {
+ "accountId": "0",
+ "containerId": "0",
+ "variableId": "1",
+ "name": "DLV - HubSpot Form ID",
+ "type": "v",
+ "parameter": [
+ {
+ "type": "TEMPLATE",
+ "key": "name",
+ "value": "form_id"
+ },
+ {
+ "type": "INTEGER",
+ "key": "dataLayerVersion",
+ "value": "2"
+ }
+ ]
+ }
+ ],
+ "fingerprint": "0",
+ "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/0/containers/0/workspaces/0"
+ }
+}
\ No newline at end of file
diff --git a/skills/conversion-tracking/assets/gtm-recipes/event-map.json b/skills/conversion-tracking/assets/gtm-recipes/event-map.json
index 7ae0cfb..1f1ac3b 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/event-map.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/event-map.json
@@ -64,6 +64,11 @@
"moment": "form submission",
"event": "gravity_form_submitted"
},
+ "hubspot-forms": {
+ "label": "HubSpot Forms",
+ "moment": "form submission",
+ "event": "hubspot_form_submitted"
+ },
"jotform": {
"label": "Jotform",
"moment": "form submission",
diff --git a/skills/conversion-tracking/assets/snippets/README.md b/skills/conversion-tracking/assets/snippets/README.md
index c627761..b3b847e 100644
--- a/skills/conversion-tracking/assets/snippets/README.md
+++ b/skills/conversion-tracking/assets/snippets/README.md
@@ -30,6 +30,7 @@ These names are load-bearing. The audit routes in SKILL.md check for exactly the
| Forminator | `forminator.js` | Form submission | `forminator_form_submitted` |
| Framer Forms | `framer-forms.js` | Form submission | `framer_form_submitted` |
| Gravity Forms | `gravity-forms.js` | Form submission | `gravity_form_submitted` |
+| HubSpot Forms | `hubspot-forms.js` | Form submission | `hubspot_form_submitted` |
| Jotform | `jotform.js` | Form submission | `jotform_form_submitted` |
| Ninja Forms | `ninja-forms.js` | Form submission | `ninja_forms_submitted` |
| Squarespace Forms | `squarespace-forms.js` | Form submission | `squarespace_form_submitted` |
@@ -73,6 +74,7 @@ Not every snippet fires on a confirmed success. Some tools expose no success sig
| `forminator.js` | Native success event (AJAX); DOM-inferred after submit (non-AJAX) | jQuery `forminator:form:submit:success` from a `form.forminator-custom-form`, each event counted once; non-AJAX: a visible `.forminator-response-message.forminator-success` inside a form without `forminator_ajax` on the returned page, once per form |
| `framer-forms.js` | DOM-inferred after submit | Framer's own form request: each OK response to a `fetch` POST to `api.framer.com/forms/v1/forms/<id>/submit` fires once (the snippet wraps `window.fetch`, so it must load before the submit); a capture-phase `submit`, or Enter in a valid Framer form, in the previous 60s only supplies `form_name`, left empty when several forms are pending |
| `gravity-forms.js` | Native success event; DOM-inferred after submit (builds without `gform.utils`) | `gform/ajax/post_ajax_submission` result with `success`, `is_valid`, `submission_type` `submit`, `is_spam` false and a positive `entry_id`, once per form and entry ID (the snippet switches non-AJAX and iframe submits to Gravity's AJAX); older builds: submit or `gform_submit_button_` click, then jQuery `gform_confirmation_loaded`, the AJAX iframe's postback or a visible `gform_confirmation_message_<id>`, or after a reload that form's confirmation within 60s with no validation errors; once per attempt |
+| `hubspot-forms.js` | Native success event | for current-editor forms, HubSpot's `hs-form-event:on-submission:success` DOM event, counted only when `HubSpotFormsV4.getFormFromEvent` returns the form and instance the event names, once per HubSpot conversion ID; for legacy-editor forms (v2.js `hbspt.forms.create`), an `hsFormCallback` message with `onFormSubmitted` posted from the page's own window, never `onFormSubmit`, which also fires for submissions that then fail. Pushes `form_id` only. Legacy forms in a cross-origin iframe aren't counted. Submissions HubSpot's bot filter files under Spam still fire HubSpot's success event, so they count |
| `jotform.js` | Native success event | `{action: 'submission-completed', formID}` postMessage from `https://form.jotform.com` or `https://submit.jotform.com`, accepted only from an iframe on the page whose `form.jotform.com/<id>` address matches the form ID; once per iframe until the page reloads. Covers the iframe and script embeds, not the full source-code embed |
| `ninja-forms.js` | Native success event | Radio `forms` channel `submit:response` with empty `errors`, no `halt`, a `form_id` matching the callback's and a saved entry ID (`actions.save.sub_id`, so the form needs its Record Submission action); once per entry ID, with no DOM fallback |
| `squarespace-forms.js` | DOM-inferred after submit | submit on a Squarespace 7.1 Form block (`form.react-form-contents`), then the first of a success marker that wasn't showing when the attempt began (`react-form-contents--submitted`, a `.form-submission-text` message or the button's `success` class), or a 2xx answer to Squarespace's own `/api/form/SaveFormSubmission` request, read from resource timing (Chromium and Firefox expose its status, Safari doesn't) and credited only when no other form was submitted around it, or either of those as a redirect form leaves the page; never on a 400 or 401, a filled anti-spam field, or a save it can't tie to one form; once per form per page view. Lightbox forms, 7.0 forms, and commerce and member forms are not covered |
diff --git a/skills/conversion-tracking/assets/snippets/hubspot-forms.js b/skills/conversion-tracking/assets/snippets/hubspot-forms.js
new file mode 100644
index 0000000..269f9ea
--- /dev/null
+++ b/skills/conversion-tracking/assets/snippets/hubspot-forms.js
@@ -0,0 +1,135 @@
+/*! HubSpot Forms conversion detection (MIT)
+ * Detects: form submission. Pushes dataLayer event: hubspot_form_submitted
+ * From the conversion-tracking skill in Marketing Skills */
+(function () {
+ if (window.__ctDetectHubspotForms) return;
+ window.__ctDetectHubspotForms = true;
+ window.dataLayer = window.dataLayer || [];
+
+ // Updated-editor conversions are keyed by HubSpot's documented conversion
+ // ID. Legacy messages use event-object identity because their documented
+ // callback payload has no conversion ID.
+ var seenConversions = {};
+ var seenLegacyEvents = typeof WeakSet === 'function' ? new WeakSet() : [];
+
+ function fireConversion(formId, conversionId, acceptedContext) {
+ var id = formId ? String(formId) : '';
+ if (typeof conversionId !== 'string' || !conversionId) return false;
+ var key = '$' + conversionId;
+ if (seenConversions[key]) return false;
+ seenConversions[key] = true;
+ var handled = false;
+ var adapter = window.__ctHubspotMethod2Handler;
+ if (typeof adapter === 'function') {
+ try {
+ handled = adapter({
+ formId: id,
+ instanceId: acceptedContext && acceptedContext.instanceId || '',
+ conversionId: conversionId,
+ form: acceptedContext && acceptedContext.form || null
+ }) === true;
+ } catch (e) {
+ handled = false;
+ }
+ }
+ if (!handled) window.dataLayer.push({ event: 'hubspot_form_submitted', form_id: id });
+ return true;
+ }
+
+ function claimLegacyEvent(event) {
+ if (!event || typeof event !== 'object') return false;
+ if (seenLegacyEvents && typeof seenLegacyEvents.has === 'function') {
+ if (seenLegacyEvents.has(event)) return false;
+ seenLegacyEvents.add(event);
+ return true;
+ }
+ if (seenLegacyEvents.indexOf(event) !== -1) return false;
+ seenLegacyEvents.push(event);
+ return true;
+ }
+
+ // ------------------------------------------------------------
+ // Path 1: current forms editor (live-verified)
+ // ------------------------------------------------------------
+ // HubSpot dispatches this on the .hs-form-frame container and lets it bubble
+ // (or on document itself when it cannot find the container), with
+ // detail = { formId, instanceId }. It only ever follows a submission
+ // HubSpot's server accepted. Listening on document in the capture phase
+ // catches both dispatch points and cannot be silenced by page code that
+ // stops the event's propagation further down.
+ function hubspotFormsApi() {
+ return window.HubSpotFormsV4 || window.HubspotFormsV4 || null;
+ }
+
+ function handleSubmissionSuccess(event) {
+ try {
+ var detail = event && event.detail;
+ if (!detail || typeof detail.formId !== 'string' || !detail.formId) return;
+ if (typeof detail.instanceId !== 'string' || !detail.instanceId) return;
+ // When HubSpot's forms API is on the page, the event must name a form
+ // instance HubSpot actually rendered here. A stray or malformed event
+ // with a made-up instance id is ignored.
+ var api = hubspotFormsApi();
+ if (!api || typeof api.getFormFromEvent !== 'function') return;
+ var form = api.getFormFromEvent(event);
+ if (!form || typeof form.getFormId !== 'function' ||
+ typeof form.getInstanceId !== 'function' ||
+ typeof form.getConversionId !== 'function') return;
+ if (form.getFormId() !== detail.formId ||
+ form.getInstanceId() !== detail.instanceId) return;
+ // HubSpot documents getConversionId as valid after successful
+ // submission. It is the stable key for event replay and repeated submits.
+ fireConversion(detail.formId, form.getConversionId(), { form: form, instanceId: detail.instanceId });
+ } catch (e) {
+ // Never throw back into HubSpot's own event dispatch.
+ }
+ }
+
+ // ------------------------------------------------------------
+ // Path 2: legacy forms editor (ported from the production module)
+ // ------------------------------------------------------------
+ // Legacy forms announce each lifecycle step with a postMessage of
+ // { type: 'hsFormCallback', eventName, id, data }. Only 'onFormSubmitted'
+ // means the submission was accepted; 'onFormSubmit' also fires for
+ // submissions that then fail validation, so it is ignored.
+ //
+ // The legacy callback payload documents its form ID but not a safe mapping
+ // from a cross-origin source WindowProxy to that ID. Accept only the inline
+ // same-window callback; cross-origin iframe messages fail closed until a
+ // vendor-supported source/form binding can be verified.
+ function isTrustedOrigin(event) {
+ return !!(event && event.source === window &&
+ event.origin === window.location.origin);
+ }
+
+ function handleMessage(event) {
+ try {
+ // Reject an unbound source before even reading its structured-clone data.
+ if (!isTrustedOrigin(event)) return;
+ var data = event && event.data;
+ if (!data || typeof data !== 'object') return;
+ if (data.type !== 'hsFormCallback') return;
+ if (data.eventName !== 'onFormSubmitted') return;
+ var formId = data.id;
+ if (typeof formId !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(formId)) return;
+ if (!claimLegacyEvent(event)) return;
+ // The documented legacy callback runs after persistence, but has no
+ // stable conversion ID. The local guard only recognizes replay of this
+ // exact MessageEvent object; a distinct event object may be a replay or a
+ // new conversion, so cross-event deduplication is not claimed.
+ var handled = false;
+ var adapter = window.__ctHubspotMethod2Handler;
+ if (typeof adapter === 'function') {
+ try {
+ handled = adapter({ formId: formId, legacyEvent: event }) === true;
+ } catch (e) { handled = false; }
+ }
+ if (!handled) window.dataLayer.push({ event: 'hubspot_form_submitted', form_id: formId });
+ } catch (e) {
+ // Never throw back into the page's own message handling.
+ }
+ }
+
+ document.addEventListener('hs-form-event:on-submission:success', handleSubmissionSuccess, true);
+ window.addEventListener('message', handleMessage, false);
+})();
diff --git a/skills/conversion-tracking/references/browser-side.md b/skills/conversion-tracking/references/browser-side.md
index 54a4676..09ee1c6 100644
--- a/skills/conversion-tracking/references/browser-side.md
+++ b/skills/conversion-tracking/references/browser-side.md
@@ -79,7 +79,7 @@ gtag('set', 'user_data', {
### The GTM route and the recipe system
-With GTM installed, prefer importing a prebuilt container over hand-building tags. This skill ships importable recipes for 21 form and booking tools, 4 universal patterns, and 6 destinations:
+With GTM installed, prefer importing a prebuilt container over hand-building tags. This skill ships importable recipes for 22 form and booking tools, 4 universal patterns, and 6 destinations:
```
python3 ../scripts/build_recipe.py --tool gravity-forms --send google-ads \
diff --git a/skills/conversion-tracking/references/conversion-moments.md b/skills/conversion-tracking/references/conversion-moments.md
index 579870d..888ea10 100644
--- a/skills/conversion-tracking/references/conversion-moments.md
+++ b/skills/conversion-tracking/references/conversion-moments.md
@@ -2,7 +2,7 @@
Load this to establish or diagnose the conversion moment. Section 1 is the lead-gen problem (success must be inferred from a browser signal, and every tool signals differently); it carries literal, grep-able strings for working from (A) form mechanics, (B) static page source, (C) a headless browser, and (D) a codebase. Section 2 covers the moments this repo ships tested detectors for. Section 3 is the long tail. Section 4 is ecommerce, where the problem mostly does not exist.
-**Fix assets.** When a finding here names a missing or wrong detection hook, the fix usually already exists in this skill. Tested listeners for 21 tools live in `../assets/snippets/` (paste-in JS) and `../assets/gtm-recipes/detect/` (importable GTM containers), both pushing the canonical dataLayer event names listed in `../assets/gtm-recipes/event-map.json` (for example `gravity_form_submitted`, `typeform_form_submitted`, `calendly_event_scheduled`). Diagnose against those exact names, fix by installing those exact assets.
+**Fix assets.** When a finding here names a missing or wrong detection hook, the fix usually already exists in this skill. Tested listeners for 22 tools live in `../assets/snippets/` (paste-in JS) and `../assets/gtm-recipes/detect/` (importable GTM containers), both pushing the canonical dataLayer event names listed in `../assets/gtm-recipes/event-map.json` (for example `gravity_form_submitted`, `typeform_form_submitted`, `calendly_event_scheduled`). Diagnose against those exact names, fix by installing those exact assets.
## 1. Lead gen
@@ -33,6 +33,7 @@ Stacking complications: multi-step forms (only final step converts; step events
- Legacy v2: `js.hsforms.net/forms/embed/v2.js` + `hbspt.forms.create({portalId, formId})`; renders INLINE mostly. Window message events: `event.data.type === 'hsFormCallback'`, `event.data.eventName` ∈ onFormReady | onFormSubmit | **onFormSubmitted** (use this, post-success) | onFormFailedValidation; `event.data.id` = form GUID.
- New v4: `js.hsforms.net/forms/embed/<portalId>.js` + `<div class="hs-form-frame" data-form-id=...>`; renders in IFRAME. Real DOM events on window: `hs-form-event:on-ready`, **`hs-form-event:on-submission:success`**, `:failed`, `:on-interaction:navigate`; `event.detail.formId`; helper `window.HubSpotFormsV4` (has getConversionId()).
- Note: `js.hs-scripts.com/<portalId>.js` is the general HubSpot tracking script - presence ≠ ad conversion tracking.
+- `hubspot-forms.js` covers both and pushes `hubspot_form_submitted` with `form_id` only, never the lead's details. On a current-editor form with the current embed code it counts `hs-form-event:on-submission:success` only when `HubSpotFormsV4.getFormFromEvent` confirms the form and instance, once per conversion ID. On a legacy-editor form with the v2.js embed it counts only an `onFormSubmitted` message posted from the page's own window, never `onFormSubmit`, which also fires for submissions that then fail. Legacy forms in a cross-origin iframe aren't counted, because their message can't be tied to a form. A current-editor form placed with the older `hbspt.forms.create()` code sent the same success event in an earlier probe but wasn't in the 15 Oct checks, and multi-step forms, several forms on one page, redirect after submit and pop-up forms weren't tested. Submissions HubSpot's bot filter files under Spam still count, because HubSpot fires its success event for them too. It was live-checked 15 Oct 2026 on a current-editor form and a legacy-editor form, and HubSpot's Submissions matched the events one for one.
**Jotform** - iframe (`form.jotform.com/<id>` or script `form.jotform.com/jsform/<id>`). After a successful submission, Jotform's iframe and script embeds send the parent page a `{action: 'submission-completed', formID}` message (live-checked on both, Oct 2026; Jotform support describes it but doesn't formally document it), which `jotform.js` listens for. The full source-code embed sends none. The Thank You → redirect setting breaks out of the iframe, navigates TOP window to your URL, and can append field values + unique {id} param - redirect is the most robust method. Tags pasted inside the Jotform builder fire on jotform.com's domain (wrong context).
@@ -188,6 +189,7 @@ python3 ../scripts/build_recipe.py --tool <slug> --send <google-ads|ga4|meta|lin
| `forminator` | Forminator | form submission | `forminator_form_submitted` |
| `framer-forms` | Framer Forms | form submission | `framer_form_submitted` |
| `gravity-forms` | Gravity Forms | form submission | `gravity_form_submitted` |
+| `hubspot-forms` | HubSpot Forms | form submission | `hubspot_form_submitted` |
| `jotform` | Jotform | form submission | `jotform_form_submitted` |
| `ninja-forms` | Ninja Forms | form submission | `ninja_forms_submitted` |
| `squarespace-forms` | Squarespace Forms | form submission | `squarespace_form_submitted` |
@@ -204,7 +206,8 @@ confirmed success state, which is exact. `acuity-scheduling` fires only when the
Acuity runs after a booking reports it, so it needs that snippet in Acuity too, and it
counts package and gift certificate purchases unless the trigger filters `acuity_type` to
`appointment`. `cal-com` also counts bookings still waiting for
-the host to confirm, marked `booking_status` `PENDING`. `framer-forms` fires when Framer's own form
+the host to confirm, marked `booking_status` `PENDING`. `hubspot-forms` also counts
+submissions HubSpot's bot filter files under Spam. `framer-forms` fires when Framer's own form
endpoint answers its request with success. `squarespace-forms` fires only once Squarespace
confirms the save, through its own success markers or its save request, never on the
submit alone. `wix-forms` fires when Wix's own thank-you
@@ -232,8 +235,8 @@ Some of these tools also have native server-side integrations from their own pla
managed tools listed there may cover them as built-in triggers; both live in `server-side.md`. What
"no snippet" means is only that this skill's free browser-side detector does not exist yet.
-**Shape 1, page listener** (29): ActiveCampaign, Kit, AWeber, Mailchimp, Klaviyo, HubSpot
-Forms, Marketo, Pipedrive, Duda, Avada, Beaver Builder, GoHighLevel, Unbounce,
+**Shape 1, page listener** (28): ActiveCampaign, Kit, AWeber, Mailchimp, Klaviyo,
+Marketo, Pipedrive, Duda, Avada, Beaver Builder, GoHighLevel, Unbounce,
Instapage, Leadpages, Paperform, Fillout, Formstack, Zoho Forms, HelloBar, OptinMonster,
ConvertBox, Thrive Leads, HubSpot Meetings, Chili Piper, Intercom, Crisp,
Tawk.to, Drift.
diff --git a/skills/conversion-tracking/references/google-ads.md b/skills/conversion-tracking/references/google-ads.md
index 71650c3..05a7e6c 100644
--- a/skills/conversion-tracking/references/google-ads.md
+++ b/skills/conversion-tracking/references/google-ads.md
@@ -16,7 +16,7 @@ Guided setup for wiring a form or booking tool to Google Ads. The agent usually
You need three things:
- Access to the Google Ads account (the user has this, you guide them).
-- The form or booking tool in play. This skill has detection recipes for 21 form and booking tools, plus 4 universal patterns (phone clicks, file downloads, thank-you pages, and generic AJAX forms). The full list with canonical dataLayer event names lives in `../assets/gtm-recipes/event-map.json` and `../assets/snippets/README.md`. Example, Gravity Forms pushes `gravity_form_submitted`. Supported tools are Acuity Scheduling, Cal.com, Calendly, Contact Form 7, Divi Forms, Elementor Forms, Fluent Forms, Formidable Forms, Forminator, Framer Forms, Gravity Forms, Jotform, Ninja Forms, Squarespace Forms, Tally, Typeform, Webflow Forms, Wix Forms, Wix Bookings, WPForms, and WS Form.
+- The form or booking tool in play. This skill has detection recipes for 22 form and booking tools, plus 4 universal patterns (phone clicks, file downloads, thank-you pages, and generic AJAX forms). The full list with canonical dataLayer event names lives in `../assets/gtm-recipes/event-map.json` and `../assets/snippets/README.md`. Example, Gravity Forms pushes `gravity_form_submitted`. Supported tools are Acuity Scheduling, Cal.com, Calendly, Contact Form 7, Divi Forms, Elementor Forms, Fluent Forms, Formidable Forms, Forminator, Framer Forms, Gravity Forms, HubSpot Forms, Jotform, Ninja Forms, Squarespace Forms, Tally, Typeform, Webflow Forms, Wix Forms, Wix Bookings, WPForms, and WS Form.
- A decision on the install path. Check the site's page source for a `GTM-` container snippet, or ask the user. If GTM is installed, use Path A. If not, use Path B. Never do both, that double counts.
Also do a quick duplicate pre-check before installing anything. Fetch the page source and look for an existing `AW-` ID, a `gtag('event', 'conversion'` call, or an existing Google Ads conversion tag inside the GTM container. If the same real-world action is already being tracked, fix or replace that setup rather than adding a second one on top. Two tags for one form is the classic overcounting setup.
@@ -54,7 +54,7 @@ End state, GTM does all the listening and firing, and nothing gets pasted into t
- **Goal.** Produce 1 GTM container file that bundles the tool's detection tag, the Google Ads conversion tag, and a Conversion Linker tag.
- **Do this.** Run this, substituting the tool key from `../assets/gtm-recipes/event-map.json` and the 2 values from Step 2. `python3 ../scripts/build_recipe.py --tool {tool} --send google-ads --conversion-id {id} --conversion-label {label} -o import-me.json` The script uses only the Python standard library and can run from any folder, paths resolve relative to the script file.
- **Expect to see.** The script prints "wrote import-me.json" plus which dataLayer event it detects and where it sends.
-- **On error.** "invalid choice" on --tool means the tool key is misspelled or unsupported, check the 25 keys in `../assets/gtm-recipes/event-map.json`. A complaint about missing --conversion-id or --conversion-label means Step 2 values were not passed.
+- **On error.** "invalid choice" on --tool means the tool key is misspelled or unsupported, check the 26 keys in `../assets/gtm-recipes/event-map.json`. A complaint about missing --conversion-id or --conversion-label means Step 2 values were not passed.
- **Acuity only.** Acuity needs a second file. Paste `../assets/snippets/acuity-scheduling-field.html` into Acuity's Custom Conversion Tracking field (Integrations, then Custom Conversion Tracking) with the site's own address in `SITES`, or no booking ever reaches the page. Acuity runs that field for package and gift certificate purchases too, so count only events where `acuity_type` is `appointment`.
**Step 4 - Import the file into GTM**