Skip to content

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

Replace the Typeform listener with the live-checked one

Aaron Beashel01c4b57c8176
diff --git a/VERSIONS.md b/VERSIONS.md
index 1fca09d..4e2d4e7 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:** 16 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.
+ - **Assets:** 17 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.
- **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/assets/gtm-recipes/detect/detect-typeform.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-typeform.json
index 5830ece..93eec3e 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-typeform.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-typeform.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "<script>\n(function () {\n if (window.__ctDetectTypeform) return;\n window.__ctDetectTypeform = true;\n window.dataLayer = window.dataLayer || [];\n\n var ORIGIN_PATTERN = /(^|\\.)typeform\\.com$/;\n\n function fireConversion(formId, responseId) {\n window.dataLayer.push({\n event: 'typeform_form_submitted',\n form_id: formId || '',\n response_id: responseId || ''\n });\n }\n\n // 'form-submit' is the confirmed message the Typeform embed SDK sends on a\n // completed submission (it carries formId and responseId). The other two\n // names are best-guess aliases kept for older or third-party embed wrappers.\n // 'embed-auto-close-popup' is deliberately NOT accepted: it is a UI close\n // signal, not a submission, and carries no responseId.\n function looksLikeTypeformSubmit(data) {\n if (!data || typeof data !== 'object') return false;\n var t = data.type;\n if (typeof t !== 'string') return false;\n return (\n t === 'form-submit' ||\n t === 'typeform.formSubmit' ||\n t === 'typeform-form-submit'\n );\n }\n\n function pickFormId(data) {\n return data.formId || data.form_id || data.formID ||\n (data.payload && (data.payload.formId || data.payload.form_id)) || '';\n }\n\n function pickResponseId(data) {\n return data.responseId || data.response_id || data.responseID ||\n (data.payload && (data.payload.responseId || data.payload.response_id)) || '';\n }\n\n function onMessage(event) {\n if (!event || !event.source) return;\n if (event.source === window) return;\n if (!event.origin || typeof event.origin !== 'string') return;\n\n var hostMatch = /^https:\\/\\/([^/]+)$/.exec(event.origin);\n if (!hostMatch) return;\n if (!ORIGIN_PATTERN.test(hostMatch[1])) return;\n\n var data = event.data;\n if (typeof data === 'string') {\n try { data = JSON.parse(data); } catch (e) { return; }\n }\n if (!data || typeof data !== 'object') return;\n if (!looksLikeTypeformSubmit(data)) return;\n\n var formId = pickFormId(data);\n var responseId = pickResponseId(data);\n if (!formId || !responseId) return;\n\n fireConversion(formId, responseId);\n }\n\n window.addEventListener('message', onMessage, false);\n})();\n</script>"
+ "value": "<script>\n(function () {\n 'use strict';\n\n // Shared recipe/template install guard. Keep this exact name so both\n // installation paths attach one message listener.\n if (window.__ctDetectTypeform) return;\n window.__ctDetectTypeform = true;\n window.dataLayer = window.dataLayer || [];\n\n var ORIGIN_PATTERN = /(^|\\.)typeform\\.com$/;\n var TYPEFORM_IFRAME_SELECTOR = 'iframe[src^=\"https://\"][src*=\".typeform.com/to/\"],iframe[src^=\"https://typeform.com/to/\"]';\n var accepted = Object.create(null);\n var trackedFrames = [];\n\n function isSafeId(value) {\n return typeof value === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(value);\n }\n\n // Match a public form ID against the URL path using CSS selectors. Do not\n // fetch, parse, retain, or serialize the iframe src; its query can contain\n // prefilled respondent data.\n function hasFormPath(iframe, formId, host) {\n if (!isSafeId(formId) || !host || !iframe || typeof iframe.matches !== 'function') return false;\n var prefix = 'iframe[src^=\"https://' + host + '/to/' + formId;\n var selectors = [\n 'iframe[src=\"https://' + host + '/to/' + formId + '\"]',\n prefix + '?\"]',\n prefix + '#\"]',\n prefix + '/\"]'\n ];\n for (var i = 0; i < selectors.length; i++) {\n try {\n if (iframe.matches(selectors[i])) return true;\n } catch (e) {\n return false;\n }\n }\n return false;\n }\n\n function isTypeformFrame(iframe) {\n if (!iframe || typeof iframe.matches !== 'function') return false;\n try { return iframe.matches(TYPEFORM_IFRAME_SELECTOR); } catch (e) { return false; }\n }\n\n function track(iframe) {\n if (!isTypeformFrame(iframe)) return;\n for (var i = 0; i < trackedFrames.length; i++) {\n if (trackedFrames[i].iframe === iframe) return;\n }\n try {\n trackedFrames.push({ iframe: iframe, source: iframe.contentWindow });\n } catch (e) {\n // If a browser denies the WindowProxy reference, fail closed for this frame.\n }\n }\n\n function scan(root) {\n if (!root || typeof root.querySelectorAll !== 'function') return;\n var frames;\n try { frames = root.querySelectorAll(TYPEFORM_IFRAME_SELECTOR); } catch (e) { return; }\n for (var i = 0; i < frames.length; i++) track(frames[i]);\n }\n\n function trackedSourceForForm(source, formId, host) {\n scan(document);\n for (var i = 0; i < trackedFrames.length; i++) {\n var tracked = trackedFrames[i];\n try {\n if (tracked.source === source && hasFormPath(tracked.iframe, formId, host)) return true;\n } catch (e) {\n // A browser may deny access to a detached frame; ignore that frame.\n }\n }\n return false;\n }\n\n function ownDataValue(object, key) {\n if (!object || typeof object !== 'object') return undefined;\n var descriptor;\n try { descriptor = Object.getOwnPropertyDescriptor(object, key); } catch (e) { return undefined; }\n return descriptor && Object.prototype.hasOwnProperty.call(descriptor, 'value')\n ? descriptor.value\n : undefined;\n }\n\n function onMessage(event) {\n if (!event || !event.source || event.source === window) return;\n var origin = event.origin;\n if (typeof origin !== 'string') return;\n var match = /^https:\\/\\/([^/:?#]+)$/.exec(origin);\n if (!match || !ORIGIN_PATTERN.test(match[1])) return;\n\n var data = event.data;\n if (!data || typeof data !== 'object') return;\n\n // Only the historically captured canonical success message is accepted.\n // Public Typeform docs document onSubmit, not raw postMessage aliases.\n if (ownDataValue(data, 'type') !== 'form-submit') return;\n var formId = ownDataValue(data, 'formId');\n var responseId = ownDataValue(data, 'responseId');\n if (!isSafeId(formId) || !isSafeId(responseId)) return;\n if (!trackedSourceForForm(event.source, formId, match[1])) return;\n\n var key = formId + '\\u0000' + responseId;\n if (accepted[key]) return;\n accepted[key] = true;\n window.dataLayer.push({\n event: 'typeform_form_submitted',\n form_id: formId,\n response_id: responseId\n });\n }\n\n scan(document);\n if (typeof MutationObserver !== 'undefined' && document.documentElement) {\n var observer = new MutationObserver(function (mutations) {\n for (var i = 0; i < mutations.length; i++) {\n var mutation = mutations[i];\n if (mutation.type === 'attributes') {\n track(mutation.target);\n continue;\n }\n var nodes = mutation.addedNodes || [];\n for (var j = 0; j < nodes.length; j++) {\n var node = nodes[j];\n if (!node) continue;\n if (node.tagName === 'IFRAME') track(node);\n else scan(node);\n }\n }\n });\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['src']\n });\n }\n\n window.addEventListener('message', onMessage, false);\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -119,4 +119,4 @@
"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/snippets/README.md b/skills/conversion-tracking/assets/snippets/README.md
index f390510..c820d68 100644
--- a/skills/conversion-tracking/assets/snippets/README.md
+++ b/skills/conversion-tracking/assets/snippets/README.md
@@ -71,7 +71,7 @@ Not every snippet fires on a confirmed success. Some tools expose no success sig
| `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 |
| `tally.js` | Native success event | `Tally.FormSubmitted` postMessage from `https://tally.so`, accepted only from a loaded `tally.so/embed`, `/r` or `/popup` iframe for the same form ID, with a submission `id` and a `fields` array; once per form and submission ID |
-| `typeform.js` | Native success event | `form-submit` postMessage from typeform.com carrying `formId` and `responseId` |
+| `typeform.js` | Native success event | `form-submit` postMessage from an https `typeform.com` origin carrying `formId` and `responseId`, accepted only from a Typeform iframe on the page whose `/to/<formId>` address matches; once per form and response ID |
| `webflow-forms.js` | DOM-inferred after submit | submit on a form in `.w-form`, then within 30s `.w-form-done` becomes visible, or Webflow's own form state shows a redirect with `success === true` (checked on jQuery `ajaxComplete`); a newly shown `.w-form-fail` or the timeout cancels, and a resubmit replaces the pending watch |
| `wix-forms.js` | DOM-inferred after submit | click on a current Wix form's `[data-hook="submit-button"]`, then within 60s Wix's own thank-you message (`[data-hook="submit-form-success-message"]`) is added inside that form; a second click refreshes the same watch. Older Wix contact forms and forms set to redirect after submit are not covered |
| `wix-scheduling.js` | DOM-inferred after submit | Book Now click stored in localStorage, then the `ThankYouPageAppDataHook.root` confirmation page renders within 10 minutes |
diff --git a/skills/conversion-tracking/assets/snippets/typeform.js b/skills/conversion-tracking/assets/snippets/typeform.js
index 0283593..2cc3d06 100644
--- a/skills/conversion-tracking/assets/snippets/typeform.js
+++ b/skills/conversion-tracking/assets/snippets/typeform.js
@@ -2,67 +2,143 @@
* Detects: form submission. Pushes dataLayer event: typeform_form_submitted
* From the conversion-tracking skill in Marketing Skills */
(function () {
+ 'use strict';
+
+ // Shared recipe/template install guard. Keep this exact name so both
+ // installation paths attach one message listener.
if (window.__ctDetectTypeform) return;
window.__ctDetectTypeform = true;
window.dataLayer = window.dataLayer || [];
var ORIGIN_PATTERN = /(^|\.)typeform\.com$/;
+ var TYPEFORM_IFRAME_SELECTOR = 'iframe[src^="https://"][src*=".typeform.com/to/"],iframe[src^="https://typeform.com/to/"]';
+ var accepted = Object.create(null);
+ var trackedFrames = [];
- function fireConversion(formId, responseId) {
- window.dataLayer.push({
- event: 'typeform_form_submitted',
- form_id: formId || '',
- response_id: responseId || ''
- });
+ function isSafeId(value) {
+ return typeof value === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(value);
}
- // 'form-submit' is the confirmed message the Typeform embed SDK sends on a
- // completed submission (it carries formId and responseId). The other two
- // names are best-guess aliases kept for older or third-party embed wrappers.
- // 'embed-auto-close-popup' is deliberately NOT accepted: it is a UI close
- // signal, not a submission, and carries no responseId.
- function looksLikeTypeformSubmit(data) {
- if (!data || typeof data !== 'object') return false;
- var t = data.type;
- if (typeof t !== 'string') return false;
- return (
- t === 'form-submit' ||
- t === 'typeform.formSubmit' ||
- t === 'typeform-form-submit'
- );
+ // Match a public form ID against the URL path using CSS selectors. Do not
+ // fetch, parse, retain, or serialize the iframe src; its query can contain
+ // prefilled respondent data.
+ function hasFormPath(iframe, formId, host) {
+ if (!isSafeId(formId) || !host || !iframe || typeof iframe.matches !== 'function') return false;
+ var prefix = 'iframe[src^="https://' + host + '/to/' + formId;
+ var selectors = [
+ 'iframe[src="https://' + host + '/to/' + formId + '"]',
+ prefix + '?"]',
+ prefix + '#"]',
+ prefix + '/"]'
+ ];
+ for (var i = 0; i < selectors.length; i++) {
+ try {
+ if (iframe.matches(selectors[i])) return true;
+ } catch (e) {
+ return false;
+ }
+ }
+ return false;
}
- function pickFormId(data) {
- return data.formId || data.form_id || data.formID ||
- (data.payload && (data.payload.formId || data.payload.form_id)) || '';
+ function isTypeformFrame(iframe) {
+ if (!iframe || typeof iframe.matches !== 'function') return false;
+ try { return iframe.matches(TYPEFORM_IFRAME_SELECTOR); } catch (e) { return false; }
}
- function pickResponseId(data) {
- return data.responseId || data.response_id || data.responseID ||
- (data.payload && (data.payload.responseId || data.payload.response_id)) || '';
+ function track(iframe) {
+ if (!isTypeformFrame(iframe)) return;
+ for (var i = 0; i < trackedFrames.length; i++) {
+ if (trackedFrames[i].iframe === iframe) return;
+ }
+ try {
+ trackedFrames.push({ iframe: iframe, source: iframe.contentWindow });
+ } catch (e) {
+ // If a browser denies the WindowProxy reference, fail closed for this frame.
+ }
}
- function onMessage(event) {
- if (!event || !event.source) return;
- if (event.source === window) return;
- if (!event.origin || typeof event.origin !== 'string') return;
+ function scan(root) {
+ if (!root || typeof root.querySelectorAll !== 'function') return;
+ var frames;
+ try { frames = root.querySelectorAll(TYPEFORM_IFRAME_SELECTOR); } catch (e) { return; }
+ for (var i = 0; i < frames.length; i++) track(frames[i]);
+ }
- var hostMatch = /^https:\/\/([^/]+)$/.exec(event.origin);
- if (!hostMatch) return;
- if (!ORIGIN_PATTERN.test(hostMatch[1])) return;
+ function trackedSourceForForm(source, formId, host) {
+ scan(document);
+ for (var i = 0; i < trackedFrames.length; i++) {
+ var tracked = trackedFrames[i];
+ try {
+ if (tracked.source === source && hasFormPath(tracked.iframe, formId, host)) return true;
+ } catch (e) {
+ // A browser may deny access to a detached frame; ignore that frame.
+ }
+ }
+ return false;
+ }
+
+ function ownDataValue(object, key) {
+ if (!object || typeof object !== 'object') return undefined;
+ var descriptor;
+ try { descriptor = Object.getOwnPropertyDescriptor(object, key); } catch (e) { return undefined; }
+ return descriptor && Object.prototype.hasOwnProperty.call(descriptor, 'value')
+ ? descriptor.value
+ : undefined;
+ }
+
+ function onMessage(event) {
+ if (!event || !event.source || event.source === window) return;
+ var origin = event.origin;
+ if (typeof origin !== 'string') return;
+ var match = /^https:\/\/([^/:?#]+)$/.exec(origin);
+ if (!match || !ORIGIN_PATTERN.test(match[1])) return;
var data = event.data;
- if (typeof data === 'string') {
- try { data = JSON.parse(data); } catch (e) { return; }
- }
if (!data || typeof data !== 'object') return;
- if (!looksLikeTypeformSubmit(data)) return;
- var formId = pickFormId(data);
- var responseId = pickResponseId(data);
- if (!formId || !responseId) return;
+ // Only the historically captured canonical success message is accepted.
+ // Public Typeform docs document onSubmit, not raw postMessage aliases.
+ if (ownDataValue(data, 'type') !== 'form-submit') return;
+ var formId = ownDataValue(data, 'formId');
+ var responseId = ownDataValue(data, 'responseId');
+ if (!isSafeId(formId) || !isSafeId(responseId)) return;
+ if (!trackedSourceForForm(event.source, formId, match[1])) return;
- fireConversion(formId, responseId);
+ var key = formId + '\u0000' + responseId;
+ if (accepted[key]) return;
+ accepted[key] = true;
+ window.dataLayer.push({
+ event: 'typeform_form_submitted',
+ form_id: formId,
+ response_id: responseId
+ });
+ }
+
+ scan(document);
+ if (typeof MutationObserver !== 'undefined' && document.documentElement) {
+ var observer = new MutationObserver(function (mutations) {
+ for (var i = 0; i < mutations.length; i++) {
+ var mutation = mutations[i];
+ if (mutation.type === 'attributes') {
+ track(mutation.target);
+ continue;
+ }
+ var nodes = mutation.addedNodes || [];
+ for (var j = 0; j < nodes.length; j++) {
+ var node = nodes[j];
+ if (!node) continue;
+ if (node.tagName === 'IFRAME') track(node);
+ else scan(node);
+ }
+ }
+ });
+ observer.observe(document.documentElement, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeFilter: ['src']
+ });
}
window.addEventListener('message', onMessage, false);