Skill Tracer
Skills › Marketing Skills › conversion-tracking › detect-ws-form.json

detect-ws-form.json

103 lines · skills/conversion-tracking/assets/gtm-recipes/detect/detect-ws-form.json at 88c79f6

1{
2 "exportFormatVersion": 2,
3 "exportTime": "2026-07-02 00:00:00",
4 "containerVersion": {
5 "path": "accounts/0/containers/0/versions/0",
6 "accountId": "0",
7 "containerId": "0",
8 "containerVersionId": "0",
9 "container": {
10 "path": "accounts/0/containers/0",
11 "accountId": "0",
12 "containerId": "0",
13 "name": "Conversion Detection - WS Form",
14 "publicId": "GTM-XXXXXXX",
15 "usageContext": [
16 "WEB"
17 ],
18 "fingerprint": "0",
19 "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/0/containers/0/workspaces/0"
20 },
21 "tag": [
22 {
23 "accountId": "0",
24 "containerId": "0",
25 "tagId": "1",
26 "name": "Conversion Detection - WS Form Submission Listener",
27 "type": "html",
28 "parameter": [
29 {
30 "type": "TEMPLATE",
31 "key": "html",
32 "value": "<script>\n(function () {\n if (window.__ctDetectWsForm) return;\n window.__ctDetectWsForm = true;\n window.dataLayer = window.dataLayer || [];\n var seenEvents = typeof WeakSet === 'function' ? new WeakSet() : null;\n var lastSuccessByInstance = {};\n function unwrap(value) { return value && value.jquery ? value[0] : (value && value[0] && value[0].nodeType ? value[0] : value); }\n function onAcceptedSubmit(event, formObject, formId, instanceId, formEl) {\n if (event && seenEvents) {\n if (seenEvents.has(event)) return;\n seenEvents.add(event);\n }\n var form = unwrap(formEl);\n if (!form || !form.matches || !form.matches('form.wsf-form')) return;\n var id;\n if (typeof formId === 'string') {\n if (!/^\\d+$/.test(formId) || Number(formId) < 1) return;\n id = formId;\n } else if (typeof formId === 'number') {\n if (!isFinite(formId) || Math.floor(formId) !== formId || formId < 1) return;\n id = String(formId);\n } else {\n return;\n }\n // WS Form can finish both requests from a double-click. Count the rapid\n // success callbacks once, without changing the form or reading answers.\n var instance = typeof instanceId === 'string' || typeof instanceId === 'number' ? instanceId : '';\n var key = id + ':' + instance;\n var now = Date.now();\n if (lastSuccessByInstance[key] !== undefined && now - lastSuccessByInstance[key] < 2000) return;\n lastSuccessByInstance[key] = now;\n var adapter = window.__ctWsFormMethod2Emit;\n if (typeof adapter === 'function') {\n try { if (adapter(form, id, instanceId) === true) return; }\n catch (e) { return; }\n }\n window.dataLayer.push({ event: 'ws_form_submitted', form_id: id });\n }\n var handlerBound = false;\n function hook() {\n if (handlerBound) return true;\n var jq = typeof jQuery !== 'undefined' ? jQuery : (typeof $ !== 'undefined' ? $ : null);\n if (!jq) return false;\n jq(document).on('wsf-submit-success', onAcceptedSubmit);\n handlerBound = true;\n return true;\n }\n if (!hook()) {\n document.addEventListener('DOMContentLoaded', hook, { once: true });\n window.addEventListener('load', hook, { once: true });\n }\n})();\n</script>"
33 },
34 {
35 "type": "BOOLEAN",
36 "key": "supportDocumentWrite",
37 "value": "false"
38 }
39 ],
40 "firingTriggerId": [
41 "2147479553"
42 ],
43 "tagFiringOption": "ONCE_PER_EVENT",
44 "monitoringMetadata": {
45 "type": "MAP"
46 },
47 "consentSettings": {
48 "consentStatus": "NOT_SET"
49 }
50 }
51 ],
52 "trigger": [
53 {
54 "accountId": "0",
55 "containerId": "0",
56 "triggerId": "2",
57 "name": "CE - WS Form Submitted",
58 "type": "CUSTOM_EVENT",
59 "customEventFilter": [
60 {
61 "type": "EQUALS",
62 "parameter": [
63 {
64 "type": "TEMPLATE",
65 "key": "arg0",
66 "value": "{{_event}}"
67 },
68 {
69 "type": "TEMPLATE",
70 "key": "arg1",
71 "value": "ws_form_submitted"
72 }
73 ]
74 }
75 ],
76 "filter": []
77 }
78 ],
79 "variable": [
80 {
81 "accountId": "0",
82 "containerId": "0",
83 "variableId": "1",
84 "name": "DLV - WS Form ID",
85 "type": "v",
86 "parameter": [
87 {
88 "type": "TEMPLATE",
89 "key": "name",
90 "value": "form_id"
91 },
92 {
93 "type": "INTEGER",
94 "key": "dataLayerVersion",
95 "value": "2"
96 }
97 ]
98 }
99 ],
100 "fingerprint": "0",
101 "tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/0/containers/0/workspaces/0"
102 }