Skip to content

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

fix: regenerate detect recipe HTML from current snippets

Corey Hainesf0719950f715
diff --git a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-contact-form-7.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-contact-form-7.json
index f771da9..6c208e2 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-contact-form-7.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-contact-form-7.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "(function () {\n if (window.__ctDetectContactForm7) return;\n window.__ctDetectContactForm7 = true;\n window.dataLayer = window.dataLayer || [];\n\n function fireConversion(formEl) {\n // Modern Contact Form 7 (verified against 6.1.6 on a live site) puts\n // data-wpcf7-id on the WRAPPING <div class=\"wpcf7\">, not on the <form>\n // element itself. Check the form first (older/other CF7 setups may\n // still stamp it there) and fall back to the wrapper.\n var formId = '';\n try {\n if (formEl && formEl.getAttribute) {\n formId = formEl.getAttribute('data-wpcf7-id') || '';\n }\n if (!formId && formEl && formEl.closest) {\n var wrap = formEl.closest('.wpcf7');\n if (wrap && wrap.getAttribute) {\n formId = wrap.getAttribute('data-wpcf7-id') || '';\n }\n }\n } catch (e) {\n // .closest unsupported in very old browsers \u2014 non-fatal, form_id stays ''\n }\n window.dataLayer.push({\n event: 'contact_form_7_submitted',\n form_id: formId\n });\n }\n\n // Fire path \u2014 Contact Form 7's own native DOM CustomEvent, dispatched on\n // the <form> element once an AJAX submission passes CF7's server-side\n // validation and spam checks, then bubbles to document. This is the ONLY\n // path this recipe tracks; a legacy non-AJAX (full page reload) CF7 setup\n // never dispatches this event at all \u2014 CF7 itself provides no client-side\n // success signal in that mode either (the real module only logs a\n // warning for it, it never fires a conversion).\n document.addEventListener('wpcf7mailsent', function (event) {\n var formEl = event && event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n fireConversion(formEl);\n }, false);\n})();"
+ "value": "<script>\n(function () {\n if (window.__ctDetectContactForm7) return;\n window.__ctDetectContactForm7 = true;\n window.dataLayer = window.dataLayer || [];\n\n function fireConversion(formEl) {\n // Modern Contact Form 7 (verified against 6.1.6 on a live site) puts\n // data-wpcf7-id on the WRAPPING <div class=\"wpcf7\">, not on the <form>\n // element itself. Check the form first (older/other CF7 setups may\n // still stamp it there) and fall back to the wrapper.\n var formId = '';\n try {\n if (formEl && formEl.getAttribute) {\n formId = formEl.getAttribute('data-wpcf7-id') || '';\n }\n if (!formId && formEl && formEl.closest) {\n var wrap = formEl.closest('.wpcf7');\n if (wrap && wrap.getAttribute) {\n formId = wrap.getAttribute('data-wpcf7-id') || '';\n }\n }\n } catch (e) {\n // .closest unsupported in very old browsers — non-fatal, form_id stays ''\n }\n window.dataLayer.push({\n event: 'contact_form_7_submitted',\n form_id: formId\n });\n }\n\n // Fire path — Contact Form 7's own native DOM CustomEvent, dispatched on\n // the <form> element once an AJAX submission passes CF7's server-side\n // validation and spam checks, then bubbles to document. This is the ONLY\n // path this recipe tracks; a legacy non-AJAX (full page reload) CF7 setup\n // never dispatches this event at all — CF7 itself provides no client-side\n // success signal in that mode either (the real module only logs a\n // warning for it, it never fires a conversion).\n document.addEventListener('wpcf7mailsent', function (event) {\n var formEl = event && event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n fireConversion(formEl);\n }, false);\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -100,4 +100,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/gtm-recipes/detect/detect-elementor-forms.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-elementor-forms.json
index 232c6b9..df9cd6f 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-elementor-forms.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-elementor-forms.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "<script>\n(function () {\n if (window.__ctDetectElementorForms) return;\n window.__ctDetectElementorForms = true;\n window.dataLayer = window.dataLayer || [];\n\n // Best-effort, non-PII identifier: the form's own id/name, or the\n // nearest ancestor carrying Elementor's standard data-id widget-instance\n // attribute. Never reads field values.\n function bestEffortFormId(formEl) {\n if (!formEl) return '';\n if (formEl.id) return formEl.id;\n var name = formEl.getAttribute && formEl.getAttribute('name');\n if (name) return name;\n try {\n var withId = formEl.closest && formEl.closest('[data-id]');\n if (withId) return withId.getAttribute('data-id') || '';\n } catch (e) {\n // .closest not available \u2014 non-fatal\n }\n return '';\n }\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'elementor_form_submitted',\n form_id: formId || ''\n });\n }\n\n // Same form-resolution chain the production module uses (event.target\n // -> most recently clicked Elementor submit button's form -> the sole\n // .elementor-form on the page) \u2014 ported here so the recipe can attach a\n // real form_id instead of firing event-only.\n var lastClickedForm = null;\n\n function trackClick(event) {\n try {\n var target = event.target;\n if (!target || !target.closest) return;\n var form = target.closest('form.elementor-form');\n if (form) lastClickedForm = form;\n } catch (e) {\n // non-fatal\n }\n }\n\n function resolveFormFromTarget(target) {\n if (!target || target === document || target === window) return null;\n try {\n if ((target.tagName || '').toLowerCase() === 'form' &&\n target.classList && target.classList.contains('elementor-form')) {\n return target;\n }\n if (target.closest) {\n var parentForm = target.closest('form.elementor-form');\n if (parentForm) return parentForm;\n }\n } catch (e) {\n // non-fatal\n }\n return null;\n }\n\n // Fire path \u2014 Elementor Pro's own jQuery event, triggered on `document`\n // once an AJAX submission passes server-side validation. This is the ONLY\n // path this recipe tracks; Elementor Pro forms submit exclusively via\n // Elementor's own AJAX pipeline, so there is no non-AJAX mode to miss.\n var successHooked = false;\n\n function hookElementorSuccess() {\n if (successHooked) return true;\n if (typeof jQuery === 'undefined' && typeof $ === 'undefined') return false;\n\n var jQ = typeof jQuery !== 'undefined' ? jQuery : $;\n jQ(document).on('submit_success', function (event) {\n var formEl = resolveFormFromTarget(event && event.target);\n if (!formEl && lastClickedForm) formEl = lastClickedForm;\n lastClickedForm = null;\n\n if (!formEl) {\n try {\n var forms = document.querySelectorAll('.elementor-form');\n if (forms.length === 1) formEl = forms[0];\n } catch (e) {\n // non-fatal\n }\n }\n\n fireConversion(bestEffortFormId(formEl));\n });\n successHooked = true;\n return true;\n }\n\n document.addEventListener('click', trackClick, true);\n\n if (!hookElementorSuccess()) {\n document.addEventListener('DOMContentLoaded', function () {\n hookElementorSuccess();\n });\n window.addEventListener('load', function () {\n hookElementorSuccess();\n });\n }\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectElementorForms) return;\n window.__ctDetectElementorForms = true;\n window.dataLayer = window.dataLayer || [];\n\n // Best-effort, non-PII identifier: the form's own id/name, or the\n // nearest ancestor carrying Elementor's standard data-id widget-instance\n // attribute. Never reads field values.\n function bestEffortFormId(formEl) {\n if (!formEl) return '';\n if (formEl.id) return formEl.id;\n var name = formEl.getAttribute && formEl.getAttribute('name');\n if (name) return name;\n try {\n var withId = formEl.closest && formEl.closest('[data-id]');\n if (withId) return withId.getAttribute('data-id') || '';\n } catch (e) {\n // .closest not available — non-fatal\n }\n return '';\n }\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'elementor_form_submitted',\n form_id: formId || ''\n });\n }\n\n // Same form-resolution chain the production module uses (event.target\n // -> most recently clicked Elementor submit button's form -> the sole\n // .elementor-form on the page) — ported here so the recipe can attach a\n // real form_id instead of firing event-only.\n var lastClickedForm = null;\n\n function trackClick(event) {\n try {\n var target = event.target;\n if (!target || !target.closest) return;\n var form = target.closest('form.elementor-form');\n if (form) lastClickedForm = form;\n } catch (e) {\n // non-fatal\n }\n }\n\n function resolveFormFromTarget(target) {\n if (!target || target === document || target === window) return null;\n try {\n if ((target.tagName || '').toLowerCase() === 'form' &&\n target.classList && target.classList.contains('elementor-form')) {\n return target;\n }\n if (target.closest) {\n var parentForm = target.closest('form.elementor-form');\n if (parentForm) return parentForm;\n }\n } catch (e) {\n // non-fatal\n }\n return null;\n }\n\n // Fire path — Elementor Pro's own jQuery event, triggered on `document`\n // once an AJAX submission passes server-side validation. This is the ONLY\n // path this recipe tracks; Elementor Pro forms submit exclusively via\n // Elementor's own AJAX pipeline, so there is no non-AJAX mode to miss.\n var successHooked = false;\n\n function hookElementorSuccess() {\n if (successHooked) return true;\n // A bare $ is only trusted when it looks like jQuery ($.fn exists), so\n // another library that claims $ cannot break the hook.\n var jQ = null;\n if (typeof jQuery !== 'undefined') jQ = jQuery;\n else if (typeof $ !== 'undefined' && typeof $.fn !== 'undefined') jQ = $;\n if (!jQ) return false;\n jQ(document).on('submit_success', function (event) {\n var formEl = resolveFormFromTarget(event && event.target);\n if (!formEl && lastClickedForm) formEl = lastClickedForm;\n lastClickedForm = null;\n\n if (!formEl) {\n try {\n var forms = document.querySelectorAll('.elementor-form');\n if (forms.length === 1) formEl = forms[0];\n } catch (e) {\n // non-fatal\n }\n }\n\n fireConversion(bestEffortFormId(formEl));\n });\n successHooked = true;\n return true;\n }\n\n document.addEventListener('click', trackClick, true);\n\n if (!hookElementorSuccess()) {\n document.addEventListener('DOMContentLoaded', function () {\n hookElementorSuccess();\n });\n window.addEventListener('load', function () {\n hookElementorSuccess();\n });\n }\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -100,4 +100,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/gtm-recipes/detect/detect-file-download.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-file-download.json
index 070a7a6..6752484 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-file-download.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-file-download.json
@@ -28,7 +28,7 @@
{
"type": "template",
"key": "html",
- "value": "<script>\n/*! File download conversion detection (MIT)\n * From the conversion-tracking skill in Marketing Skills\n * Detects: click on a downloadable file link. Pushes dataLayer event: file_download\n */\n(function () {\n if (window.__ctDetectFileDownload) return;\n window.__ctDetectFileDownload = true;\n window.dataLayer = window.dataLayer || [];\n\n /* For gated content that is NOT gated: price lists, brochures, spec\n sheets, lead magnets served as a direct link. If the download sits\n behind a form, track the form instead \u2014 that is where the lead is.\n\n GA4 already collects file_download as an enhanced measurement event.\n Use this when you need the same signal in Google Ads or Meta, which\n do not. */\n\n // EDIT if you serve other formats.\n var EXTENSIONS = [\n 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',\n 'csv', 'zip', 'rar', '7z', 'dmg', 'exe', 'pkg',\n 'mp3', 'mp4', 'mov', 'wav', 'txt', 'rtf'\n ];\n\n var DEDUPE_MS = 2000;\n var lastUrl = null;\n var lastAt = 0;\n\n function extensionOf(url) {\n try {\n // Strip query and hash before reading the extension, so\n // /brochure.pdf?utm_source=x still resolves to \"pdf\".\n var path = String(url || '').split('#')[0].split('?')[0];\n var name = path.substring(path.lastIndexOf('/') + 1);\n var dot = name.lastIndexOf('.');\n if (dot < 0) return null;\n var ext = name.substring(dot + 1).toLowerCase();\n for (var i = 0; i < EXTENSIONS.length; i++) {\n if (EXTENSIONS[i] === ext) return ext;\n }\n } catch (e) { /* fall through */ }\n return null;\n }\n\n function fileNameOf(url) {\n try {\n var path = String(url || '').split('#')[0].split('?')[0];\n return decodeURIComponent(path.substring(path.lastIndexOf('/') + 1));\n } catch (e) {\n return '';\n }\n }\n\n function handleClick(event) {\n try {\n if (event.button !== undefined && event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n\n var target = event.target;\n if (!target || !target.closest) return;\n\n var link = target.closest('a[href]');\n if (!link) return;\n\n // Resolve relative hrefs against the current page. .href does this for\n // us where available; getAttribute would leave \"/files/x.pdf\" relative.\n var url = link.href || link.getAttribute('href');\n if (!url) return;\n\n // An anchor carrying the download attribute is a download regardless\n // of extension, so honour that too.\n var ext = extensionOf(url);\n var forced = link.hasAttribute && link.hasAttribute('download');\n if (!ext && !forced) return;\n\n var now = new Date().getTime();\n if (url === lastUrl && (now - lastAt) < DEDUPE_MS) return;\n lastUrl = url;\n lastAt = now;\n\n window.dataLayer.push({\n event: 'file_download',\n file_name: fileNameOf(url),\n file_extension: ext || '',\n file_url: url,\n link_text: (link.textContent || '').trim().slice(0, 100),\n page_path: window.location.pathname\n });\n } catch (e) {\n // Never throw back into the page's own click handling.\n }\n }\n\n document.addEventListener('click', handleClick, false);\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectFileDownload) return;\n window.__ctDetectFileDownload = true;\n window.dataLayer = window.dataLayer || [];\n\n /* For gated content that is NOT gated: price lists, brochures, spec\n sheets, lead magnets served as a direct link. If the download sits\n behind a form, track the form instead — that is where the lead is.\n\n GA4 already collects file_download as an enhanced measurement event.\n Use this when you need the same signal in Google Ads or Meta, which\n do not. */\n\n // EDIT if you serve other formats.\n var EXTENSIONS = [\n 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',\n 'csv', 'zip', 'rar', '7z', 'dmg', 'exe', 'pkg',\n 'mp3', 'mp4', 'mov', 'wav', 'txt', 'rtf'\n ];\n\n var DEDUPE_MS = 2000;\n var lastUrl = null;\n var lastAt = 0;\n\n function extensionOf(url) {\n try {\n // Strip query and hash before reading the extension, so\n // /brochure.pdf?utm_source=x still resolves to \"pdf\".\n var path = String(url || '').split('#')[0].split('?')[0];\n var name = path.substring(path.lastIndexOf('/') + 1);\n var dot = name.lastIndexOf('.');\n if (dot < 0) return null;\n var ext = name.substring(dot + 1).toLowerCase();\n for (var i = 0; i < EXTENSIONS.length; i++) {\n if (EXTENSIONS[i] === ext) return ext;\n }\n } catch (e) { /* fall through */ }\n return null;\n }\n\n function fileNameOf(url) {\n try {\n var path = String(url || '').split('#')[0].split('?')[0];\n return decodeURIComponent(path.substring(path.lastIndexOf('/') + 1));\n } catch (e) {\n return '';\n }\n }\n\n function handleClick(event) {\n try {\n if (event.button !== undefined && event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n\n var target = event.target;\n if (!target || !target.closest) return;\n\n var link = target.closest('a[href]');\n if (!link) return;\n\n // Resolve relative hrefs against the current page. .href does this for\n // us where available; getAttribute would leave \"/files/x.pdf\" relative.\n var url = link.href || link.getAttribute('href');\n if (!url) return;\n\n // An anchor carrying the download attribute is a download regardless\n // of extension, so honour that too.\n var ext = extensionOf(url);\n var forced = link.hasAttribute && link.hasAttribute('download');\n if (!ext && !forced) return;\n\n var now = new Date().getTime();\n if (url === lastUrl && (now - lastAt) < DEDUPE_MS) return;\n lastUrl = url;\n lastAt = now;\n\n window.dataLayer.push({\n event: 'file_download',\n file_name: fileNameOf(url),\n file_extension: ext || '',\n file_url: url,\n link_text: (link.textContent || '').trim().slice(0, 100),\n page_path: window.location.pathname\n });\n } catch (e) {\n // Never throw back into the page's own click handling.\n }\n }\n\n document.addEventListener('click', handleClick, false);\n})();\n</script>"
},
{
"type": "boolean",
diff --git a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-framer-forms.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-framer-forms.json
index 543aedc..de6b6f5 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-framer-forms.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-framer-forms.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "<script>\n(function () {\n if (window.__ctDetectFramerForms) return;\n window.__ctDetectFramerForms = true;\n window.dataLayer = window.dataLayer || [];\n\n function fireConversion(formName) {\n window.dataLayer.push({\n event: 'framer_form_submitted',\n form_name: formName || ''\n });\n }\n\n function isFramerForm(formEl) {\n if (!formEl) return false;\n if (formEl.hasAttribute && formEl.hasAttribute('data-framer-name')) return true;\n var cls = typeof formEl.className === 'string' ? formEl.className : '';\n if (/(^|\\s)framer-[A-Za-z0-9_-]+/.test(cls)) return true;\n try {\n if (formEl.closest && formEl.closest('[data-framer-component-type]')) return true;\n if (formEl.closest && formEl.closest('[data-framer-name]')) return true;\n } catch (e) {\n // .closest not available \u2014 fall through\n }\n return false;\n }\n\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n if (!isFramerForm(formEl)) return;\n\n var formName = formEl.getAttribute('data-framer-name') || formEl.id || '';\n\n fireConversion(formName);\n } catch (e) {\n // Never throw back into Framer's own form handling.\n }\n }\n\n if (typeof document !== 'undefined' && document.addEventListener) {\n document.addEventListener('submit', handleSubmit, true);\n }\n})();\n</script>"
+ "value": "<script>\n(function () {\n // SUBMIT-BASED BEST EFFORT. Framer exposes no success event, so this fires\n // on a submit that passed browser validation and that no other handler\n // cancelled. A server-side rejection or spam block still counts. For exact\n // counts, set the form to redirect to a thank-you page and use\n // thank-you-page.js instead.\n if (window.__ctDetectFramerForms) return;\n window.__ctDetectFramerForms = true;\n window.dataLayer = window.dataLayer || [];\n\n function fireConversion(formName) {\n window.dataLayer.push({\n event: 'framer_form_submitted',\n form_name: formName || ''\n });\n }\n\n function isFramerForm(formEl) {\n if (!formEl) return false;\n if (formEl.hasAttribute && formEl.hasAttribute('data-framer-name')) return true;\n var cls = typeof formEl.className === 'string' ? formEl.className : '';\n if (/(^|\\s)framer-[A-Za-z0-9_-]+/.test(cls)) return true;\n try {\n if (formEl.closest && formEl.closest('[data-framer-component-type]')) return true;\n if (formEl.closest && formEl.closest('[data-framer-name]')) return true;\n } catch (e) {\n // .closest not available — fall through\n }\n return false;\n }\n\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n if (!isFramerForm(formEl)) return;\n\n // A submission another handler already cancelled never happened.\n if (event.defaultPrevented) return;\n\n // Constraint validation gate: an invalid form cannot have submitted.\n try {\n if (typeof formEl.checkValidity === 'function' && formEl.checkValidity() === false) return;\n } catch (e) {\n // constraint validation unavailable — fall through\n }\n\n var formName = formEl.getAttribute('data-framer-name') || formEl.id || '';\n\n fireConversion(formName);\n } catch (e) {\n // Never throw back into Framer's own form handling.\n }\n }\n\n if (typeof document !== 'undefined' && document.addEventListener) {\n // Bubble phase deliberately. A capture-phase listener runs BEFORE the\n // form's own handlers, so it would count submissions that Framer's\n // validation goes on to cancel.\n document.addEventListener('submit', handleSubmit, false);\n }\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -100,4 +100,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/gtm-recipes/detect/detect-generic-ajax-form.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-generic-ajax-form.json
index 19c0cee..2457464 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-generic-ajax-form.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-generic-ajax-form.json
@@ -28,7 +28,7 @@
{
"type": "template",
"key": "html",
- "value": "<script>\n/*! Generic AJAX form conversion detection (MIT)\n * From the conversion-tracking skill in Marketing Skills\n * Detects: inline success after an AJAX form submit. Pushes dataLayer event: form_submitted\n */\n(function () {\n if (window.__ctDetectGenericAjaxForm) return;\n window.__ctDetectGenericAjaxForm = true;\n window.dataLayer = window.dataLayer || [];\n\n /* Last-resort fallback for form tools this repo has no specific snippet\n for. It infers success from the page changing after a submit, which is\n weaker than a tool's own success event. Always prefer a named snippet\n from snippets/ when one exists for the tool.\n\n The design deliberately refuses to fire on submit alone. A submit is an\n attempt; only a success signal appearing afterwards, with no visible\n validation error, is treated as a conversion. */\n\n var SUCCESS_WINDOW_MS = 7000; // how long to wait for a success signal\n var watchers = [];\n\n function fire(formEl) {\n window.dataLayer.push({\n event: 'form_submitted',\n form_id: (formEl && formEl.id) || '',\n form_name: (formEl && formEl.getAttribute && formEl.getAttribute('name')) || '',\n page_path: window.location.pathname,\n detection: 'generic-ajax'\n });\n }\n\n function isHidden(el) {\n try {\n if (el.hidden) return true;\n if (el.getAttribute && el.getAttribute('aria-hidden') === 'true') return true;\n var view = el.ownerDocument && el.ownerDocument.defaultView;\n if (view && view.getComputedStyle) {\n var cs = view.getComputedStyle(el);\n if (cs && (cs.display === 'none' || cs.visibility === 'hidden')) return true;\n }\n } catch (e) { /* fall through */ }\n return false;\n }\n\n // A visible validation error means the submit was rejected. This is the\n // guard that stops a failed submission being counted.\n function hasVisibleError(root) {\n try {\n var nodes = root.querySelectorAll(\n '[aria-invalid=\"true\"], .error, .is-invalid, [class*=\"error\"], [role=\"alert\"]'\n );\n for (var i = 0; i < nodes.length; i++) {\n if (isHidden(nodes[i])) continue;\n if (nodes[i].getAttribute &&\n nodes[i].getAttribute('aria-invalid') === 'true') return true;\n if ((nodes[i].textContent || '').trim()) return true;\n }\n } catch (e) { /* fall through */ }\n return false;\n }\n\n function looksLikeSuccess(node) {\n if (!node || node.nodeType !== 1) return false;\n try {\n var cls = (typeof node.className === 'string' ? node.className : '') || '';\n var hook = (node.getAttribute && node.getAttribute('data-hook')) || '';\n if (/error|invalid/i.test(cls + ' ' + hook)) return false;\n\n // Structural marker the tool itself stamped. Strongest signal here.\n if (/success|confirmation|thank/i.test(cls + ' ' + hook)) return true;\n\n var text = (node.textContent || '').trim();\n if (!text || text.length > 300) return false;\n if (/error|required|invalid|try again|please enter|please fill/i.test(text)) return false;\n // Still in flight, not done.\n if (/^(submitting|sending|loading|processing|please wait|one moment)\\b/i.test(text)) return false;\n return /thank you|thanks|success|received|we'?ll be in touch|message sent|submitted/i.test(text);\n } catch (e) {\n return false;\n }\n }\n\n function watch(formEl) {\n for (var i = 0; i < watchers.length; i++) {\n if (watchers[i].form === formEl) return; // already watching this form\n }\n\n var entry = { form: formEl };\n watchers.push(entry);\n\n var done = false;\n var observer = null;\n var timer = null;\n\n function stop() {\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timer) { clearTimeout(timer); }\n for (var j = 0; j < watchers.length; j++) {\n if (watchers[j] === entry) { watchers.splice(j, 1); break; }\n }\n }\n\n function evaluate(nodes) {\n if (done) return;\n // A visible error anywhere in the form means rejection. Give up.\n if (hasVisibleError(formEl)) { stop(); return; }\n for (var k = 0; k < nodes.length; k++) {\n if (looksLikeSuccess(nodes[k])) {\n fire(formEl);\n stop();\n return;\n }\n }\n }\n\n try {\n observer = new MutationObserver(function (mutations) {\n var added = [];\n for (var a = 0; a < mutations.length; a++) {\n var m = mutations[a];\n for (var b = 0; b < m.addedNodes.length; b++) added.push(m.addedNodes[b]);\n if (m.type === 'attributes' && m.target) added.push(m.target);\n }\n if (added.length) evaluate(added);\n });\n // Watch the form's container, so a success panel that REPLACES the form\n // is still seen. Falls back to the form itself.\n var scope = formEl.parentNode || formEl;\n observer.observe(scope, {\n childList: true, subtree: true,\n attributes: true, attributeFilter: ['class', 'style', 'hidden', 'aria-hidden']\n });\n } catch (e) {\n stop();\n return;\n }\n\n timer = setTimeout(stop, SUCCESS_WINDOW_MS);\n }\n\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n\n // Another handler already cancelled this submission.\n if (event.defaultPrevented) return;\n\n // Constraint validation gate: an invalid form cannot have submitted.\n try {\n if (typeof formEl.checkValidity === 'function' &&\n formEl.checkValidity() === false) return;\n } catch (e) { /* validation unavailable \u2014 fall through */ }\n\n watch(formEl);\n } catch (e) {\n // Never throw back into the page's own form handling.\n }\n }\n\n // Bubble phase so the tool's own handlers run first.\n document.addEventListener('submit', handleSubmit, false);\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectGenericAjaxForm) return;\n window.__ctDetectGenericAjaxForm = true;\n window.dataLayer = window.dataLayer || [];\n\n /* Last-resort fallback for form tools this repo has no specific snippet\n for. It infers success from the page changing after a submit, which is\n weaker than a tool's own success event. Always prefer a named snippet\n from snippets/ when one exists for the tool.\n\n The design deliberately refuses to fire on submit alone. A submit is an\n attempt; only a success signal appearing afterwards, with no visible\n validation error, is treated as a conversion. */\n\n var SUCCESS_WINDOW_MS = 7000; // how long to wait for a success signal\n var watchers = [];\n\n function fire(formEl) {\n window.dataLayer.push({\n event: 'form_submitted',\n form_id: (formEl && formEl.id) || '',\n form_name: (formEl && formEl.getAttribute && formEl.getAttribute('name')) || '',\n page_path: window.location.pathname,\n detection: 'generic-ajax'\n });\n }\n\n function isHidden(el) {\n try {\n if (el.hidden) return true;\n if (el.getAttribute && el.getAttribute('aria-hidden') === 'true') return true;\n var view = el.ownerDocument && el.ownerDocument.defaultView;\n if (view && view.getComputedStyle) {\n var cs = view.getComputedStyle(el);\n if (cs && (cs.display === 'none' || cs.visibility === 'hidden')) return true;\n }\n } catch (e) { /* fall through */ }\n return false;\n }\n\n // A visible validation error means the submit was rejected. This is the\n // guard that stops a failed submission being counted.\n function hasVisibleError(root) {\n try {\n var nodes = root.querySelectorAll(\n '[aria-invalid=\"true\"], .error, .is-invalid, [class*=\"error\"], [role=\"alert\"]'\n );\n for (var i = 0; i < nodes.length; i++) {\n if (isHidden(nodes[i])) continue;\n if (nodes[i].getAttribute &&\n nodes[i].getAttribute('aria-invalid') === 'true') return true;\n if ((nodes[i].textContent || '').trim()) return true;\n }\n } catch (e) { /* fall through */ }\n return false;\n }\n\n function looksLikeSuccess(node) {\n if (!node || node.nodeType !== 1) return false;\n try {\n var cls = (typeof node.className === 'string' ? node.className : '') || '';\n var hook = (node.getAttribute && node.getAttribute('data-hook')) || '';\n if (/error|invalid/i.test(cls + ' ' + hook)) return false;\n\n // Structural marker the tool itself stamped. Strongest signal here.\n if (/success|confirmation|thank/i.test(cls + ' ' + hook)) return true;\n\n var text = (node.textContent || '').trim();\n if (!text || text.length > 300) return false;\n if (/error|required|invalid|try again|please enter|please fill/i.test(text)) return false;\n // Still in flight, not done.\n if (/^(submitting|sending|loading|processing|please wait|one moment)\\b/i.test(text)) return false;\n return /thank you|thanks|success|received|we'?ll be in touch|message sent|submitted/i.test(text);\n } catch (e) {\n return false;\n }\n }\n\n function watch(formEl) {\n for (var i = 0; i < watchers.length; i++) {\n if (watchers[i].form === formEl) return; // already watching this form\n }\n\n var entry = { form: formEl };\n watchers.push(entry);\n\n var done = false;\n var observer = null;\n var timer = null;\n\n function stop() {\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timer) { clearTimeout(timer); }\n for (var j = 0; j < watchers.length; j++) {\n if (watchers[j] === entry) { watchers.splice(j, 1); break; }\n }\n }\n\n function evaluate(nodes) {\n if (done) return;\n // A visible error anywhere in the form means rejection. Give up.\n if (hasVisibleError(formEl)) { stop(); return; }\n for (var k = 0; k < nodes.length; k++) {\n if (looksLikeSuccess(nodes[k])) {\n fire(formEl);\n stop();\n return;\n }\n }\n }\n\n try {\n observer = new MutationObserver(function (mutations) {\n var added = [];\n for (var a = 0; a < mutations.length; a++) {\n var m = mutations[a];\n for (var b = 0; b < m.addedNodes.length; b++) added.push(m.addedNodes[b]);\n if (m.type === 'attributes' && m.target) added.push(m.target);\n }\n if (added.length) evaluate(added);\n });\n // Watch the form's container, so a success panel that REPLACES the form\n // is still seen. Falls back to the form itself.\n var scope = formEl.parentNode || formEl;\n observer.observe(scope, {\n childList: true, subtree: true,\n attributes: true, attributeFilter: ['class', 'style', 'hidden', 'aria-hidden']\n });\n } catch (e) {\n stop();\n return;\n }\n\n timer = setTimeout(stop, SUCCESS_WINDOW_MS);\n }\n\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n\n // Another handler already cancelled this submission.\n if (event.defaultPrevented) return;\n\n // Constraint validation gate: an invalid form cannot have submitted.\n try {\n if (typeof formEl.checkValidity === 'function' &&\n formEl.checkValidity() === false) return;\n } catch (e) { /* validation unavailable — fall through */ }\n\n watch(formEl);\n } catch (e) {\n // Never throw back into the page's own form handling.\n }\n }\n\n // Bubble phase so the tool's own handlers run first.\n document.addEventListener('submit', handleSubmit, false);\n})();\n</script>"
},
{
"type": "boolean",
diff --git a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-jotform.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-jotform.json
index 5577192..5b2d6c0 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-jotform.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-jotform.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "<script>\n(function () {\n if (window.__ctDetectJotform) return;\n window.__ctDetectJotform = true;\n window.dataLayer = window.dataLayer || [];\n\n var JOTFORM_FORM_ID_RE = /^\\d{10,}$/;\n var JOTFORM_SUBMIT_ACTION_RE = /^https?:\\/\\/submit\\.jotform\\.com\\//i;\n\n function isJotformInlineForm(formEl) {\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return false;\n var hasClass = formEl.classList && formEl.classList.contains('jotform-form');\n var action = formEl.getAttribute && formEl.getAttribute('action');\n var hasAction = action && JOTFORM_SUBMIT_ACTION_RE.test(action);\n if (!hasClass && !hasAction) return false;\n var id = formEl.id || '';\n if (!JOTFORM_FORM_ID_RE.test(id)) return false;\n return true;\n }\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'jotform_form_submitted',\n form_id: formId || ''\n });\n }\n\n document.addEventListener('submit', function (event) {\n var formEl = event.target;\n if (!isJotformInlineForm(formEl)) return;\n fireConversion(formEl.id);\n }, true);\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectJotform) return;\n window.__ctDetectJotform = true;\n window.dataLayer = window.dataLayer || [];\n\n // Two embed styles, two signals of different strength:\n //\n // 1. IFRAME embed (the default Jotform embed code). The form iframe posts\n // { action: 'submission-completed', formID: '<id>' } to the parent page\n // once Jotform has accepted the submission. This is a real success\n // signal: spam blocks and server-side rejections never send it. Jotform\n // support has confirmed the message exists but says it is not a public\n // API and may change, so re-verify it when Jotform ships embed changes.\n //\n // 2. SOURCE-CODE embed (the form's raw HTML pasted into the page, a\n // <form class=\"jotform-form\"> posting to submit.jotform.com). The page\n // navigates away to Jotform on submit, so there is no success signal\n // this page can observe. This path is SUBMIT-BASED BEST EFFORT: it fires\n // on a submit that passed the browser's own validation and that no other\n // handler cancelled, so a server-side rejection, CAPTCHA failure or spam\n // block still counts. Prefer the iframe embed, or a thank-you page\n // redirect plus thank-you-page.js, when accuracy matters.\n\n var JOTFORM_FORM_ID_RE = /^\\d{10,}$/;\n var JOTFORM_SUBMIT_ACTION_RE = /^https?:\\/\\/submit\\.jotform\\.com\\//i;\n var JOTFORM_ORIGIN_RE = /(^|\\.)jotform(eu)?\\.com$/;\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'jotform_form_submitted',\n form_id: formId || ''\n });\n }\n\n // ---- Path 1: iframe embed, native success message ----\n\n function handleMessage(event) {\n try {\n if (!event || !event.source || event.source === window) return;\n if (!event.origin || typeof event.origin !== 'string') return;\n var hostMatch = /^https:\\/\\/([^/]+)$/.exec(event.origin);\n if (!hostMatch || !JOTFORM_ORIGIN_RE.test(hostMatch[1])) return;\n\n var data = event.data;\n if (typeof data === 'string') {\n if (data.indexOf('submission-completed') === -1) return;\n try { data = JSON.parse(data); } catch (e) { return; }\n }\n if (!data || typeof data !== 'object') return;\n if (data.action !== 'submission-completed') return;\n\n var formId = String(data.formID || data.formId || '');\n if (!JOTFORM_FORM_ID_RE.test(formId)) return;\n\n fireConversion(formId);\n } catch (e) {\n // Never throw back into the page's own message handling.\n }\n }\n\n window.addEventListener('message', handleMessage, false);\n\n // ---- Path 2: source-code embed, submit-based best effort ----\n\n function isJotformInlineForm(formEl) {\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return false;\n var hasClass = formEl.classList && formEl.classList.contains('jotform-form');\n var action = formEl.getAttribute && formEl.getAttribute('action');\n var hasAction = action && JOTFORM_SUBMIT_ACTION_RE.test(action);\n if (!hasClass && !hasAction) return false;\n var id = formEl.id || '';\n if (!JOTFORM_FORM_ID_RE.test(id)) return false;\n return true;\n }\n\n // Bubble phase deliberately. A capture-phase listener runs BEFORE the form's\n // own handlers, so it would count submissions Jotform's validation cancels.\n document.addEventListener('submit', function (event) {\n var formEl = event.target;\n if (!isJotformInlineForm(formEl)) return;\n\n // A submission another handler already cancelled never happened.\n if (event.defaultPrevented) return;\n\n // Constraint validation gate: an invalid form cannot have submitted.\n try {\n if (typeof formEl.checkValidity === 'function' && formEl.checkValidity() === false) return;\n } catch (e) {\n // constraint validation unavailable — fall through\n }\n\n fireConversion(formEl.id);\n }, false);\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -100,4 +100,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/gtm-recipes/detect/detect-phone-click.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-phone-click.json
index aa4b15c..b7b42a4 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-phone-click.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-phone-click.json
@@ -28,7 +28,7 @@
{
"type": "template",
"key": "html",
- "value": "<script>\n/*! Phone call click detection (MIT)\n * From the conversion-tracking skill in Marketing Skills\n * Detects: click on a tel: link. Pushes dataLayer event: phone_click\n */\n(function () {\n if (window.__ctDetectPhoneClick) return;\n window.__ctDetectPhoneClick = true;\n window.dataLayer = window.dataLayer || [];\n\n // A click is a call INTENT, not a completed call. On desktop especially,\n // many tel: clicks never become a conversation. Count it as a lead signal,\n // and prefer a call tracking number if you need answered-call accuracy.\n\n // Ignore a repeat click on the same number inside this window. Impatient\n // double-taps on mobile are common and would otherwise double count.\n var DEDUPE_MS = 2000;\n var lastNumber = null;\n var lastAt = 0;\n\n function normalise(href) {\n // tel:+61 (2) 1234-5678 -> +61212345678 . Keeps a leading +, drops the\n // punctuation humans put in phone numbers so dedupe compares like for like.\n var raw = String(href || '').replace(/^tel:/i, '');\n try { raw = decodeURIComponent(raw); } catch (e) { /* leave as-is */ }\n var plus = raw.trim().charAt(0) === '+' ? '+' : '';\n return plus + raw.replace(/[^0-9]/g, '');\n }\n\n function handleClick(event) {\n try {\n // Left click only, and not a modified click that opens elsewhere.\n if (event.button !== undefined && event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n\n var target = event.target;\n if (!target || !target.closest) return;\n\n // closest() because the click usually lands on an icon or span INSIDE\n // the anchor, not the anchor itself.\n var link = target.closest('a[href^=\"tel:\"], a[href^=\"TEL:\"]');\n if (!link) return;\n\n var number = normalise(link.getAttribute('href'));\n if (!number) return;\n\n var now = new Date().getTime();\n if (number === lastNumber && (now - lastAt) < DEDUPE_MS) return;\n lastNumber = number;\n lastAt = now;\n\n window.dataLayer.push({\n event: 'phone_click',\n phone_number: number,\n // The visible text, useful when a site shows different numbers per\n // location or campaign. Trimmed and capped so a whole button's worth\n // of markup text never lands in the dataLayer.\n link_text: (link.textContent || '').trim().slice(0, 100),\n page_path: window.location.pathname\n });\n } catch (e) {\n // Never throw back into the page's own click handling.\n }\n }\n\n // Bubble phase: a tel: click has no validation to lose a race with, and\n // bubbling means anything that legitimately cancels the click wins first.\n document.addEventListener('click', handleClick, false);\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectPhoneClick) return;\n window.__ctDetectPhoneClick = true;\n window.dataLayer = window.dataLayer || [];\n\n // A click is a call INTENT, not a completed call. On desktop especially,\n // many tel: clicks never become a conversation. Count it as a lead signal,\n // and prefer a call tracking number if you need answered-call accuracy.\n\n // Ignore a repeat click on the same number inside this window. Impatient\n // double-taps on mobile are common and would otherwise double count.\n var DEDUPE_MS = 2000;\n var lastNumber = null;\n var lastAt = 0;\n\n function normalise(href) {\n // tel:+61 (2) 1234-5678 -> +61212345678 . Keeps a leading +, drops the\n // punctuation humans put in phone numbers so dedupe compares like for like.\n var raw = String(href || '').replace(/^tel:/i, '');\n try { raw = decodeURIComponent(raw); } catch (e) { /* leave as-is */ }\n var plus = raw.trim().charAt(0) === '+' ? '+' : '';\n return plus + raw.replace(/[^0-9]/g, '');\n }\n\n function handleClick(event) {\n try {\n // Left click only, and not a modified click that opens elsewhere.\n if (event.button !== undefined && event.button !== 0) return;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n\n var target = event.target;\n if (!target || !target.closest) return;\n\n // closest() because the click usually lands on an icon or span INSIDE\n // the anchor, not the anchor itself.\n var link = target.closest('a[href^=\"tel:\"], a[href^=\"TEL:\"]');\n if (!link) return;\n\n var number = normalise(link.getAttribute('href'));\n if (!number) return;\n\n var now = new Date().getTime();\n if (number === lastNumber && (now - lastAt) < DEDUPE_MS) return;\n lastNumber = number;\n lastAt = now;\n\n // PII: if the site shows visitor-specific numbers (an account page, a\n // CRM-driven \"your rep\" number), drop phone_number and link_text here.\n window.dataLayer.push({\n event: 'phone_click',\n phone_number: number,\n // The visible text, useful when a site shows different numbers per\n // location or campaign. Trimmed and capped so a whole button's worth\n // of markup text never lands in the dataLayer.\n link_text: (link.textContent || '').trim().slice(0, 100),\n page_path: window.location.pathname\n });\n } catch (e) {\n // Never throw back into the page's own click handling.\n }\n }\n\n // Bubble phase: a tel: click has no validation to lose a race with, and\n // bubbling means anything that legitimately cancels the click wins first.\n document.addEventListener('click', handleClick, false);\n})();\n</script>"
},
{
"type": "boolean",
diff --git a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-thank-you-page.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-thank-you-page.json
index b20ba39..3873325 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-thank-you-page.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-thank-you-page.json
@@ -28,7 +28,7 @@
{
"type": "template",
"key": "html",
- "value": "<script>\n/*! Thank-you page conversion detection (MIT)\n * From the conversion-tracking skill in Marketing Skills\n * Detects: arrival on a confirmation page. Pushes dataLayer event: thank_you_page_view\n */\n(function () {\n if (window.__ctDetectThankYouPage) return;\n window.__ctDetectThankYouPage = true;\n window.dataLayer = window.dataLayer || [];\n\n /* ---------------------------------------------------------------\n EDIT THIS. Paths that mean \"the conversion happened\".\n Matched against location.pathname, case-insensitively, as a\n prefix. '/thank-you' matches '/thank-you' and '/thank-you/order/9'.\n --------------------------------------------------------------- */\n var THANK_YOU_PATHS = [\n '/thank-you',\n '/thanks',\n '/confirmation',\n '/success'\n ];\n\n // Set true only if your confirmation page is genuinely reachable more than\n // once per conversion and you want every view counted. Leave false.\n var COUNT_EVERY_VIEW = false;\n\n var fired = {};\n\n function matches(path) {\n var p = String(path || '').toLowerCase();\n for (var i = 0; i < THANK_YOU_PATHS.length; i++) {\n var want = String(THANK_YOU_PATHS[i] || '').toLowerCase();\n if (want && p.indexOf(want) === 0) return want;\n }\n return null;\n }\n\n function check() {\n try {\n var path = window.location.pathname;\n var matched = matches(path);\n if (!matched) return;\n\n // A refresh or a back-button return to the confirmation page would\n // otherwise count a second conversion for the same lead. Keyed on the\n // full path so two different confirmations still both count.\n if (!COUNT_EVERY_VIEW && fired[path]) return;\n fired[path] = true;\n\n window.dataLayer.push({\n event: 'thank_you_page_view',\n page_path: path,\n matched_rule: matched\n });\n } catch (e) {\n // Never throw back into the page.\n }\n }\n\n // Single-page apps are the reason this is not just a one-shot call. A\n // React, Vue or Next site changes the URL without a page load, so no\n // pageview ever fires and a thank-you page TRIGGER silently counts zero.\n // Wrapping history means we see those route changes too.\n function wrapHistory(method) {\n var original = window.history[method];\n if (typeof original !== 'function') return;\n window.history[method] = function () {\n var result = original.apply(this, arguments);\n try { setTimeout(check, 0); } catch (e) { /* ignore */ }\n return result;\n };\n }\n\n try {\n wrapHistory('pushState');\n wrapHistory('replaceState');\n window.addEventListener('popstate', function () { setTimeout(check, 0); });\n } catch (e) {\n // History API unavailable \u2014 the initial check below still runs.\n }\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', check);\n } else {\n check();\n }\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectThankYouPage) return;\n window.__ctDetectThankYouPage = true;\n window.dataLayer = window.dataLayer || [];\n\n /* ---------------------------------------------------------------\n EDIT THIS. Paths that mean \"the conversion happened\".\n Matched against location.pathname, case-insensitively, as a\n prefix. '/thank-you' matches '/thank-you' and '/thank-you/order/9'.\n --------------------------------------------------------------- */\n var THANK_YOU_PATHS = [\n '/thank-you',\n '/thanks',\n '/confirmation',\n '/success'\n ];\n\n // Set true only if your confirmation page is genuinely reachable more than\n // once per conversion and you want every view counted. Leave false.\n var COUNT_EVERY_VIEW = false;\n\n var fired = {};\n\n function matches(path) {\n var p = String(path || '').toLowerCase();\n for (var i = 0; i < THANK_YOU_PATHS.length; i++) {\n var want = String(THANK_YOU_PATHS[i] || '').toLowerCase();\n if (want && p.indexOf(want) === 0) return want;\n }\n return null;\n }\n\n function check() {\n try {\n var path = window.location.pathname;\n var matched = matches(path);\n if (!matched) return;\n\n // A refresh or a back-button return to the confirmation page would\n // otherwise count a second conversion for the same lead. Keyed on the\n // full path so two different confirmations still both count.\n if (!COUNT_EVERY_VIEW && fired[path]) return;\n fired[path] = true;\n\n window.dataLayer.push({\n event: 'thank_you_page_view',\n page_path: path,\n matched_rule: matched\n });\n } catch (e) {\n // Never throw back into the page.\n }\n }\n\n // Single-page apps are the reason this is not just a one-shot call. A\n // React, Vue or Next site changes the URL without a page load, so no\n // pageview ever fires and a thank-you page TRIGGER silently counts zero.\n // Wrapping history means we see those route changes too.\n function wrapHistory(method) {\n var original = window.history[method];\n if (typeof original !== 'function') return;\n window.history[method] = function () {\n var result = original.apply(this, arguments);\n try { setTimeout(check, 0); } catch (e) { /* ignore */ }\n return result;\n };\n }\n\n try {\n wrapHistory('pushState');\n wrapHistory('replaceState');\n window.addEventListener('popstate', function () { setTimeout(check, 0); });\n } catch (e) {\n // History API unavailable — the initial check below still runs.\n }\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', check);\n } else {\n check();\n }\n})();\n</script>"
},
{
"type": "boolean",
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 663491b..79b0f07 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 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 t === 'embed-auto-close-popup'\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 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>"
},
{
"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/gtm-recipes/detect/detect-wix-forms.json b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-wix-forms.json
index beb5401..b095b35 100644
--- a/skills/conversion-tracking/assets/gtm-recipes/detect/detect-wix-forms.json
+++ b/skills/conversion-tracking/assets/gtm-recipes/detect/detect-wix-forms.json
@@ -29,7 +29,7 @@
{
"type": "TEMPLATE",
"key": "html",
- "value": "<script>\n(function () {\n if (window.__ctDetectWixForms) return;\n window.__ctDetectWixForms = true;\n window.dataLayer = window.dataLayer || [];\n\n // How long, after a New-form Submit click, we wait for a success signal\n // before giving up (treating it as a validation failure / no-op).\n var SUCCESS_WINDOW_MS = 7000;\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'wix_form_submitted',\n form_id: formId || ''\n });\n }\n\n // ---- Form detection ----\n\n // New Wix Forms carry data-hook markers: the form itself is\n // data-hook=\"form-<uuid>\", fields are wrapped in\n // data-hook=\"form-field-...\", and the submit control is\n // data-hook=\"submit-button\".\n function isNewWixForm(root) {\n if (!root) return false;\n try {\n var hook = root.getAttribute ? root.getAttribute('data-hook') : null;\n if (hook && hook.indexOf('form-') === 0 && hook.indexOf('form-field-') !== 0) {\n return true;\n }\n if (root.querySelector &&\n (root.querySelector('[data-hook^=\"form-field-\"]') ||\n root.querySelector('[data-hook=\"submit-button\"]'))) {\n return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // Old Wix Forms render inputs as Wix components: id=\"input_comp-...\".\n function isOldWixForm(formEl) {\n if (!formEl || !formEl.querySelector) return false;\n try {\n if (formEl.querySelector('input[id^=\"input_comp-\"]')) return true;\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // ---- OLD Wix forms: native submit (Pattern A) ----\n // Capture phase so this runs before Wix's own handler can clear/detach\n // the form. New forms are explicitly excluded \u2014 they have no native\n // submit and are handled by the click path below.\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n if (isNewWixForm(formEl)) return; // click path owns new forms\n if (!isOldWixForm(formEl)) return;\n\n fireConversion(formEl.id);\n } catch (e) {\n // Never throw back into Wix's own form handling.\n }\n }\n\n // ---- NEW Wix forms: submit-button click + confirmed success ----\n\n // Watchers currently in flight, keyed by form root, so duplicate click\n // events Wix emits for a single Submit press don't arm two watchers. A\n // re-click on a watched root REFRESHES the existing watcher instead of\n // being dropped, so a visitor who fails validation, fixes a field, and\n // clicks again inside the window gets a fresh verdict.\n var activeWatchers = [];\n\n function findWatcher(root) {\n for (var w = 0; w < activeWatchers.length; w++) {\n if (activeWatchers[w].root === root) return activeWatchers[w];\n }\n return null;\n }\n\n function findNewFormRoot(btn) {\n var root = btn.closest ? btn.closest('form') : null;\n if (root && isNewWixForm(root)) return root;\n if (btn.closest) {\n var alt = btn.closest('[data-hook=\"form-root\"]') || btn.closest('[data-hook^=\"form-\"]');\n if (alt && isNewWixForm(alt)) return alt;\n }\n return null;\n }\n\n // Sorts a candidate node into one of two evidence tiers:\n // 'structural' \u2014 a marker Wix's own runtime stamps on success (a\n // data-hook or class name containing \"success\") \u2014 sufficient alone.\n // 'status' \u2014 readable confirmation-ish text (ARIA live region or\n // English thank-you wording) \u2014 corroboration only, never sufficient\n // alone (live regions also announce in-progress states).\n // null \u2014 not evidence.\n function classifySuccessNode(node) {\n if (!node || node.nodeType !== 1) return null;\n try {\n var hook = node.getAttribute ? node.getAttribute('data-hook') : null;\n if (hook && /error/i.test(hook)) return null;\n if (node.getAttribute && node.getAttribute('aria-busy') === 'true') return null;\n var cls = (typeof node.className === 'string' ? node.className : '') || '';\n if (/error/i.test(cls)) return null;\n if ((hook && /success/i.test(hook)) || /success/i.test(cls)) return 'structural';\n var text = (node.textContent || '').trim();\n if (!text) return null;\n if (/error|required|invalid|try again|please enter|please fill/i.test(text)) return null;\n var isSuccessText =\n /thank|success|received|in touch|submitted|message sent|got it|appreciate|subscrib/i.test(text);\n if (!isSuccessText &&\n /^(submitting|sending|loading|processing|please wait|one moment)\\b/i.test(text)) {\n return null;\n }\n if (node.getAttribute && node.getAttribute('role') === 'status') return 'status';\n if (isSuccessText) return 'status';\n } catch (e) {\n // fall through\n }\n return null;\n }\n\n // Wix marks failed fields with an \"error\" data-hook slot and/or\n // aria-invalid=\"true\" on the input \u2014 visible ones mean the submit was\n // rejected.\n function isNodeHidden(el) {\n try {\n if (el.hidden) return true;\n if (el.getAttribute && el.getAttribute('aria-hidden') === 'true') return true;\n var view = el.ownerDocument && el.ownerDocument.defaultView;\n if (view && view.getComputedStyle) {\n var cs = view.getComputedStyle(el);\n if (cs && (cs.display === 'none' || cs.visibility === 'hidden')) return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // Ancestor-aware hiding check, capped at the observed container.\n function isConcealed(el, stopAt) {\n var node = el;\n var depth = 0;\n while (node && node.nodeType === 1 && depth < 12) {\n if (isNodeHidden(node)) return true;\n if (node === stopAt) break;\n node = node.parentNode;\n depth++;\n }\n return false;\n }\n\n function hasVisibleValidationErrors(root) {\n if (!root || !root.querySelectorAll) return false;\n try {\n var nodes = root.querySelectorAll('[data-hook*=\"error\"], [aria-invalid=\"true\"]');\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n if (isNodeHidden(node)) continue;\n if (node.getAttribute && node.getAttribute('aria-invalid') === 'true') return true;\n if ((node.textContent || '').trim()) return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n function watchForSuccess(root, formId, pagehideTrusted) {\n var entry = { root: root, refresh: refresh };\n activeWatchers.push(entry);\n\n var fired = false;\n var timer = null;\n var observer = null;\n var pagehideArmed = false;\n // Corroboration state: a status/text confirmation was seen this\n // attempt. Text alone never fires \u2014 it only lets the weak structural\n // signals (form concealed / removed) confirm.\n var statusSeen = false;\n\n // Snapshot the controls that currently hold a value, so we can detect\n // Wix clearing the form on success. Values themselves are never read\n // for content \u2014 only used to test \"was non-empty, now empty\".\n var tracked = [];\n function snapshotTracked() {\n tracked = [];\n try {\n var inputs = root.querySelectorAll('input, textarea, select');\n for (var i = 0; i < inputs.length; i++) {\n var el = inputs[i];\n if ((el.type || '') === 'hidden') continue;\n if ((el.value || '') !== '') tracked.push(el);\n }\n } catch (e) {\n // fall through\n }\n }\n snapshotTracked();\n\n function armPagehide() {\n if (pagehideArmed) return;\n try {\n window.addEventListener('pagehide', onPageHide, true);\n pagehideArmed = true;\n } catch (e) {\n // fall through\n }\n }\n\n function disarmPagehide() {\n if (!pagehideArmed) return;\n try { window.removeEventListener('pagehide', onPageHide, true); } catch (e) {}\n pagehideArmed = false;\n }\n\n function startTimer() {\n if (timer) clearTimeout(timer);\n timer = setTimeout(function() {\n if (!fired) cleanup(); // no success signal within window \u2014 not firing\n }, SUCCESS_WINDOW_MS);\n }\n\n // A later click on the same root \u2014 Wix's duplicate click event for one\n // press, or a real re-submit after the visitor corrected a failed\n // field. Everything reflects the LATEST attempt.\n function refresh(nextFormId, nextPagehideTrusted) {\n if (fired) return;\n formId = nextFormId;\n statusSeen = false;\n snapshotTracked();\n if (nextPagehideTrusted) armPagehide();\n else disarmPagehide();\n startTimer();\n }\n\n function cleanup() {\n if (timer) { clearTimeout(timer); timer = null; }\n if (observer) { try { observer.disconnect(); } catch (e) {} observer = null; }\n disarmPagehide();\n var idx = activeWatchers.indexOf(entry);\n if (idx !== -1) activeWatchers.splice(idx, 1);\n }\n\n function fire() {\n if (fired) return;\n fired = true;\n fireConversion(formId);\n cleanup();\n }\n\n function inputsCleared() {\n if (!tracked.length) return false;\n for (var i = 0; i < tracked.length; i++) {\n var el = tracked[i];\n if (el && el.isConnected && (el.value || '') !== '') return false;\n }\n return true; // every previously-filled control is now empty or gone\n }\n\n function noteEvidence(node, structuralOnly) {\n if (!node || node === scope) return false;\n var tier = classifySuccessNode(node);\n if (tier === 'structural' && !isConcealed(node, scope)) {\n fire();\n return true;\n }\n if (!structuralOnly && tier === 'status') statusSeen = true;\n return false;\n }\n\n function onMutations(muts) {\n if (fired) return;\n var removed = !root.isConnected;\n if (!removed && inputsCleared()) { fire(); return; } // Wix reset the form\n for (var i = 0; i < muts.length; i++) {\n var added = muts[i].addedNodes || [];\n for (var j = 0; j < added.length; j++) {\n var node = added[j];\n if (noteEvidence(node, false)) return;\n if (node && node.nodeType === 3 && noteEvidence(muts[i].target, false)) return;\n }\n if (muts[i].type === 'attributes' && noteEvidence(muts[i].target, true)) return;\n }\n // Removal/concealment alone are too weak to fire \u2014 closing a modal or\n // an SPA page swap looks the same with no submit behind it. A\n // status/text message seen in the same attempt corroborates.\n if (statusSeen && (removed || isConcealed(root, scope))) {\n fire();\n }\n }\n\n function onPageHide() {\n // A visitor who failed Wix's validation and then left the page also\n // produces a pagehide \u2014 visible error indicators mean no submit\n // happened.\n if (hasVisibleValidationErrors(root)) return;\n fire();\n }\n\n // Scope the observer to the form's container \u2014 success messages appear\n // here and form removal shows up as a childList change on the parent.\n var scope = root.parentNode || document.body;\n try {\n observer = new MutationObserver(onMutations);\n observer.observe(scope, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class', 'hidden', 'aria-hidden'],\n });\n } catch (e) {\n // MutationObserver unavailable \u2014 rely on pagehide + timeout only\n }\n\n if (pagehideTrusted) armPagehide();\n\n startTimer();\n }\n\n function handleClick(event) {\n try {\n var target = event.target;\n if (!target || !target.closest) return;\n\n var btn = target.closest('[data-hook=\"submit-button\"]');\n if (!btn) return;\n\n var root = findNewFormRoot(btn);\n if (!root) return;\n\n var formId = root.getAttribute ? (root.getAttribute('data-hook') || root.id || '') : (root.id || '');\n\n // A form invalid under native constraint validation at click time\n // cannot have submitted, so a later pagehide must not confirm it.\n // Structural success signals stay armed regardless \u2014 they only ever\n // come from Wix itself, after an actual successful submit.\n var pagehideTrusted = true;\n try {\n if (typeof root.checkValidity === 'function' && !root.checkValidity()) {\n pagehideTrusted = false;\n }\n } catch (e) {\n // constraint validation unavailable\n }\n\n var existing = findWatcher(root);\n if (existing) {\n existing.refresh(formId, pagehideTrusted);\n return;\n }\n\n watchForSuccess(root, formId, pagehideTrusted);\n } catch (e) {\n // Never throw back into Wix's own click handling.\n }\n }\n\n if (typeof document !== 'undefined' && document.addEventListener) {\n document.addEventListener('submit', handleSubmit, true); // OLD forms\n document.addEventListener('click', handleClick, true); // NEW forms\n }\n})();\n</script>"
+ "value": "<script>\n(function () {\n if (window.__ctDetectWixForms) return;\n window.__ctDetectWixForms = true;\n window.dataLayer = window.dataLayer || [];\n\n // How long, after a New-form Submit click, we wait for a success signal\n // before giving up (treating it as a validation failure / no-op).\n var SUCCESS_WINDOW_MS = 7000;\n\n function fireConversion(formId) {\n window.dataLayer.push({\n event: 'wix_form_submitted',\n form_id: formId || ''\n });\n }\n\n // ---- Form detection ----\n\n // New Wix Forms carry data-hook markers: the form itself is\n // data-hook=\"form-<uuid>\", fields are wrapped in\n // data-hook=\"form-field-...\", and the submit control is\n // data-hook=\"submit-button\".\n function isNewWixForm(root) {\n if (!root) return false;\n try {\n var hook = root.getAttribute ? root.getAttribute('data-hook') : null;\n if (hook && hook.indexOf('form-') === 0 && hook.indexOf('form-field-') !== 0) {\n return true;\n }\n if (root.querySelector &&\n (root.querySelector('[data-hook^=\"form-field-\"]') ||\n root.querySelector('[data-hook=\"submit-button\"]'))) {\n return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // Old Wix Forms render inputs as Wix components: id=\"input_comp-...\".\n function isOldWixForm(formEl) {\n if (!formEl || !formEl.querySelector) return false;\n try {\n if (formEl.querySelector('input[id^=\"input_comp-\"]')) return true;\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // ---- OLD Wix forms: native submit (Pattern A) ----\n // Capture phase so this runs before Wix's own handler can clear/detach\n // the form. New forms are explicitly excluded — they have no native\n // submit and are handled by the click path below.\n function handleSubmit(event) {\n try {\n var formEl = event.target;\n if (!formEl || (formEl.tagName || '').toLowerCase() !== 'form') return;\n if (isNewWixForm(formEl)) return; // click path owns new forms\n if (!isOldWixForm(formEl)) return;\n\n // A submission another handler already cancelled never happened.\n if (event.defaultPrevented) return;\n\n // Constraint validation gate: an invalid form cannot have submitted.\n try {\n if (typeof formEl.checkValidity === 'function' && formEl.checkValidity() === false) return;\n } catch (e) {\n // constraint validation unavailable — fall through\n }\n\n fireConversion(formEl.id);\n } catch (e) {\n // Never throw back into Wix's own form handling.\n }\n }\n\n // ---- NEW Wix forms: submit-button click + confirmed success ----\n\n // Watchers currently in flight, keyed by form root, so duplicate click\n // events Wix emits for a single Submit press don't arm two watchers. A\n // re-click on a watched root REFRESHES the existing watcher instead of\n // being dropped, so a visitor who fails validation, fixes a field, and\n // clicks again inside the window gets a fresh verdict.\n var activeWatchers = [];\n\n function findWatcher(root) {\n for (var w = 0; w < activeWatchers.length; w++) {\n if (activeWatchers[w].root === root) return activeWatchers[w];\n }\n return null;\n }\n\n function findNewFormRoot(btn) {\n var root = btn.closest ? btn.closest('form') : null;\n if (root && isNewWixForm(root)) return root;\n if (btn.closest) {\n var alt = btn.closest('[data-hook=\"form-root\"]') || btn.closest('[data-hook^=\"form-\"]');\n if (alt && isNewWixForm(alt)) return alt;\n }\n return null;\n }\n\n // Sorts a candidate node into one of two evidence tiers:\n // 'structural' — a marker Wix's own runtime stamps on success (a\n // data-hook or class name containing \"success\") — sufficient alone.\n // 'status' — readable confirmation-ish text (ARIA live region or\n // English thank-you wording) — corroboration only, never sufficient\n // alone (live regions also announce in-progress states).\n // null — not evidence.\n function classifySuccessNode(node) {\n if (!node || node.nodeType !== 1) return null;\n try {\n var hook = node.getAttribute ? node.getAttribute('data-hook') : null;\n if (hook && /error/i.test(hook)) return null;\n if (node.getAttribute && node.getAttribute('aria-busy') === 'true') return null;\n var cls = (typeof node.className === 'string' ? node.className : '') || '';\n if (/error/i.test(cls)) return null;\n if ((hook && /success/i.test(hook)) || /success/i.test(cls)) return 'structural';\n var text = (node.textContent || '').trim();\n if (!text) return null;\n if (/error|required|invalid|try again|please enter|please fill/i.test(text)) return null;\n var isSuccessText =\n /thank|success|received|in touch|submitted|message sent|got it|appreciate|subscrib/i.test(text);\n if (!isSuccessText &&\n /^(submitting|sending|loading|processing|please wait|one moment)\\b/i.test(text)) {\n return null;\n }\n if (node.getAttribute && node.getAttribute('role') === 'status') return 'status';\n if (isSuccessText) return 'status';\n } catch (e) {\n // fall through\n }\n return null;\n }\n\n // Wix marks failed fields with an \"error\" data-hook slot and/or\n // aria-invalid=\"true\" on the input — visible ones mean the submit was\n // rejected.\n function isNodeHidden(el) {\n try {\n if (el.hidden) return true;\n if (el.getAttribute && el.getAttribute('aria-hidden') === 'true') return true;\n var view = el.ownerDocument && el.ownerDocument.defaultView;\n if (view && view.getComputedStyle) {\n var cs = view.getComputedStyle(el);\n if (cs && (cs.display === 'none' || cs.visibility === 'hidden')) return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n // Ancestor-aware hiding check, capped at the observed container.\n function isConcealed(el, stopAt) {\n var node = el;\n var depth = 0;\n while (node && node.nodeType === 1 && depth < 12) {\n if (isNodeHidden(node)) return true;\n if (node === stopAt) break;\n node = node.parentNode;\n depth++;\n }\n return false;\n }\n\n function hasVisibleValidationErrors(root) {\n if (!root || !root.querySelectorAll) return false;\n try {\n var nodes = root.querySelectorAll('[data-hook*=\"error\"], [aria-invalid=\"true\"]');\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n if (isNodeHidden(node)) continue;\n if (node.getAttribute && node.getAttribute('aria-invalid') === 'true') return true;\n if ((node.textContent || '').trim()) return true;\n }\n } catch (e) {\n // fall through\n }\n return false;\n }\n\n function watchForSuccess(root, formId, pagehideTrusted) {\n var entry = { root: root, refresh: refresh };\n activeWatchers.push(entry);\n\n var fired = false;\n var timer = null;\n var observer = null;\n var pagehideArmed = false;\n // Corroboration state: a status/text confirmation was seen this\n // attempt. Text alone never fires — it only lets the weak structural\n // signals (form concealed / removed) confirm.\n var statusSeen = false;\n\n // Snapshot the controls that currently hold a value, so we can detect\n // Wix clearing the form on success. Values themselves are never read\n // for content — only used to test \"was non-empty, now empty\".\n var tracked = [];\n function snapshotTracked() {\n tracked = [];\n try {\n var inputs = root.querySelectorAll('input, textarea, select');\n for (var i = 0; i < inputs.length; i++) {\n var el = inputs[i];\n if ((el.type || '') === 'hidden') continue;\n if ((el.value || '') !== '') tracked.push(el);\n }\n } catch (e) {\n // fall through\n }\n }\n snapshotTracked();\n\n function armPagehide() {\n if (pagehideArmed) return;\n try {\n window.addEventListener('pagehide', onPageHide, true);\n pagehideArmed = true;\n } catch (e) {\n // fall through\n }\n }\n\n function disarmPagehide() {\n if (!pagehideArmed) return;\n try { window.removeEventListener('pagehide', onPageHide, true); } catch (e) {}\n pagehideArmed = false;\n }\n\n function startTimer() {\n if (timer) clearTimeout(timer);\n timer = setTimeout(function() {\n if (!fired) cleanup(); // no success signal within window — not firing\n }, SUCCESS_WINDOW_MS);\n }\n\n // A later click on the same root — Wix's duplicate click event for one\n // press, or a real re-submit after the visitor corrected a failed\n // field. Everything reflects the LATEST attempt.\n function refresh(nextFormId, nextPagehideTrusted) {\n if (fired) return;\n formId = nextFormId;\n statusSeen = false;\n snapshotTracked();\n if (nextPagehideTrusted) armPagehide();\n else disarmPagehide();\n startTimer();\n }\n\n function cleanup() {\n if (timer) { clearTimeout(timer); timer = null; }\n if (observer) { try { observer.disconnect(); } catch (e) {} observer = null; }\n disarmPagehide();\n var idx = activeWatchers.indexOf(entry);\n if (idx !== -1) activeWatchers.splice(idx, 1);\n }\n\n function fire() {\n if (fired) return;\n fired = true;\n fireConversion(formId);\n cleanup();\n }\n\n function inputsCleared() {\n if (!tracked.length) return false;\n for (var i = 0; i < tracked.length; i++) {\n var el = tracked[i];\n if (el && el.isConnected && (el.value || '') !== '') return false;\n }\n return true; // every previously-filled control is now empty or gone\n }\n\n function noteEvidence(node, structuralOnly) {\n if (!node || node === scope) return false;\n var tier = classifySuccessNode(node);\n if (tier === 'structural' && !isConcealed(node, scope)) {\n fire();\n return true;\n }\n if (!structuralOnly && tier === 'status') statusSeen = true;\n return false;\n }\n\n function onMutations(muts) {\n if (fired) return;\n var removed = !root.isConnected;\n if (!removed && inputsCleared()) { fire(); return; } // Wix reset the form\n for (var i = 0; i < muts.length; i++) {\n var added = muts[i].addedNodes || [];\n for (var j = 0; j < added.length; j++) {\n var node = added[j];\n if (noteEvidence(node, false)) return;\n if (node && node.nodeType === 3 && noteEvidence(muts[i].target, false)) return;\n }\n if (muts[i].type === 'attributes' && noteEvidence(muts[i].target, true)) return;\n }\n // Removal/concealment alone are too weak to fire — closing a modal or\n // an SPA page swap looks the same with no submit behind it. A\n // status/text message seen in the same attempt corroborates.\n if (statusSeen && (removed || isConcealed(root, scope))) {\n fire();\n }\n }\n\n function onPageHide() {\n // A visitor who failed Wix's validation and then left the page also\n // produces a pagehide — visible error indicators mean no submit\n // happened.\n if (hasVisibleValidationErrors(root)) return;\n fire();\n }\n\n // Scope the observer to the form's container — success messages appear\n // here and form removal shows up as a childList change on the parent.\n var scope = root.parentNode || document.body;\n try {\n observer = new MutationObserver(onMutations);\n observer.observe(scope, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class', 'hidden', 'aria-hidden'],\n });\n } catch (e) {\n // MutationObserver unavailable — rely on pagehide + timeout only\n }\n\n if (pagehideTrusted) armPagehide();\n\n startTimer();\n }\n\n function handleClick(event) {\n try {\n var target = event.target;\n if (!target || !target.closest) return;\n\n var btn = target.closest('[data-hook=\"submit-button\"]');\n if (!btn) return;\n\n var root = findNewFormRoot(btn);\n if (!root) return;\n\n var formId = root.getAttribute ? (root.getAttribute('data-hook') || root.id || '') : (root.id || '');\n\n // A form invalid under native constraint validation at click time\n // cannot have submitted, so a later pagehide must not confirm it.\n // Structural success signals stay armed regardless — they only ever\n // come from Wix itself, after an actual successful submit.\n var pagehideTrusted = true;\n try {\n if (typeof root.checkValidity === 'function' && !root.checkValidity()) {\n pagehideTrusted = false;\n }\n } catch (e) {\n // constraint validation unavailable\n }\n\n var existing = findWatcher(root);\n if (existing) {\n existing.refresh(formId, pagehideTrusted);\n return;\n }\n\n watchForSuccess(root, formId, pagehideTrusted);\n } catch (e) {\n // Never throw back into Wix's own click handling.\n }\n }\n\n if (typeof document !== 'undefined' && document.addEventListener) {\n // Bubble phase for submit: a capture-phase listener runs before Wix's own\n // handlers and would count submissions its validation goes on to cancel.\n document.addEventListener('submit', handleSubmit, false); // OLD forms\n document.addEventListener('click', handleClick, true); // NEW forms\n }\n})();\n</script>"
},
{
"type": "BOOLEAN",
@@ -100,4 +100,4 @@
"fingerprint": "0",
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/0/containers/0/workspaces/0"
}
-}
\ No newline at end of file
+}