HomeEA · Use Case: Contact & Complaint Form › Implementation

Implementation

Purpose: Non-PII form tracking code.

Who this page is for

AudienceWhy it matters to you
DevelopersImplement safely

Implementation: Contact Form

// Track form start (when page loads)
window.addEventListener("load", () => {
  window.adobeDataLayer.push({
    event: "form_started",
    form: {
      type: "unknown" // will be filled when user picks
    }
  });
});

// Track form type selection
document.addEventListener("change", (e) => {
  if (e.target.name === "formType") {
    window.adobeDataLayer.push({
      form: { type: e.target.value } // "contact" or "complaint"
    });
  }
});

// Track form submit
document.getElementById("contactForm").addEventListener("submit", (e) => {
  e.preventDefault();
  
  const formType = document.querySelector('input[name="formType"]:checked').value;
  
  window.adobeDataLayer.push({
    event: "form_submitted",
    form: { type: formType }
  });
  
  // Send form data to backend (not to Adobe)
  submitForm();
});

---

Next: QA and validation

Quick navigation