Form data pushed to dataLayer (potential PII leak)
Detects Custom HTML tags that push raw form data into the dataLayer, exposing potential PII to every tag in the container.
Summary
- rule_id —
datalayer-pii-push - purpose — Detect Custom HTML tags pushing raw form data into the dataLayer
- effect — Form field values (email, phone, names) exposed to every tag in the container
- layer — container
- reversibility — non-destructive
What fires this
The rule checks active Custom HTML tags where codeAnalysis.hasDataLayerPush is true and the tag code matches at least one of four form-serialization patterns: form.vals(), form.serialize(), .val() used in a serialization context, or variable names matching formValues, formData, or form_data. All four patterns indicate raw form data is being collected before the dataLayer.push() call. Paused tags are excluded.
Why it matters
Once form data lands in the dataLayer, every tag in the container can read it — including ad pixels and third-party scripts. Form fields commonly contain email addresses, phone numbers, and names. The exposure propagates to all listening tags simultaneously, with no further action required by the tag author. This makes it one of the highest-leverage PII leaks in a GTM (Google Tag Manager) container. Regulatory: GDPR Art. 5 (data minimization), GDPR Art. 6 (lawful basis), CCPA/CPRA.
Before / after
// Raw form data pushed to dataLayer
var formData = $('form').serialize()
dataLayer.push({
event: 'form_submit',
formData: formData // contains email, phone, names — flagged
})
// Push only non-PII identifiers
dataLayer.push({
event: 'form_submit',
formId: $('form').attr('id'),
formName: $('form').attr('name'),
formStatus: 'submitted'
})
Remediation
- Open each flagged Custom HTML tag and locate the form-serialization call (
form.serialize(),form.vals(),.val(), or the named variable). - Identify which field values the downstream tags actually consume.
- Replace the serialization call with explicit pushes of non-PII identifiers: form ID, form name, submission status.
- If a specific field value is required (such as product type from a quote form), hash it with SHA-256 before pushing — never push the raw value.
- Remove the serialization variable entirely from the tag code.
- Verify downstream tags receive the data they need without raw field values present in the dataLayer.
Metadata
- Severity
- high
- Tier
- error
- Category
- pii
- Layer
- container
- Version
- 1
- Effort
2hr(about 2 hours)- Reversibility
- non-destructive
- Regulatory
- GDPR Art. 5 (data minimization), GDPR Art. 6 (lawful basis), CCPA/CPRA
See also
- PII rules — other rules in this category
- Base64 encoding used for PII — related PII encoding pattern
- Health score — how this rule contributes to the score
Examples
curl https://developer.tagmanifest.com/v1/evaluate-rule \
-H "Authorization: Bearer $TM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rule_id":"datalayer-pii-push","url":"https://example.com"}'
User: Run datalayer-pii-push on https://example.com
# Tool call
{
"tool": "evaluate_rule",
"arguments": {
"rule_id": "datalayer-pii-push",
"url": "https://example.com"
}
}