window.addEventListener("message", function (event) { if (!event.data || typeof event.data !== "object") return; if (event.data.type !== "hsFormCallback") return; const eventName = event.data.eventName; if (eventName !== "onFormSubmitted") return; console.log("✅ hsFormCallback:", eventName); console.log("RAW event.data:", event.data); const data = event.data.data || {}; const submissionResult = data.submissionResult || {}; const fieldsA = submissionResult.fields; // your current path const fieldsB = submissionResult.submissionValues; // sometimes used const fieldsC = data.submissionValues; // sometimes used const fieldsD = data.fields; // sometimes used console.log("fieldsA (submissionResult.fields):", fieldsA); console.log("fieldsB (submissionResult.submissionValues):", fieldsB); console.log("fieldsC (data.submissionValues):", fieldsC); console.log("fieldsD (data.fields):", fieldsD); const fields = Array.isArray(fieldsA) ? fieldsA : (fieldsB && typeof fieldsB === "object") ? Object.entries(fieldsB).map(([name, value]) => ({ name, value })) : (fieldsC && typeof fieldsC === "object") ? Object.entries(fieldsC).map(([name, value]) => ({ name, value })) : Array.isArray(fieldsD) ? fieldsD : []; console.log("Normalized fields:", fields); console.table(fields.map(f => ({ name: f.name, value: f.value }))); const getField = (name) => { const f = fields.find(x => (x.name || "").toLowerCase() === name.toLowerCase()); return f?.value || ""; }; window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: "hubspot_form_submit", email: getField("email"), phone: getField("phone"), first_name: getField("firstname"), last_name: getField("lastname"), zip: getField("zip") }); console.log("Pushed to dataLayer:", window.dataLayer[window.dataLayer.length - 1]); }); Skip to content
Eco Home Heating and Cooling Experts
  • Heating
    • Heating Installation
    • Heating Maintenance
    • Heating Repair
    • Furnace
    • Heat Pumps
    • Mini Splits
    • Service and Maintenance Plans
  • Cooling
    • AC Installation
    • AC Maintenance
    • Air Conditioner Repair
    • Heat Pumps
    • Mini Splits
    • Service and Maintenance Plans
  • New Construction
  • Offers
    • No Money Out Of Pocket
    • Free Quote
    • $0 Down 0% Interest
    • $29 Tune Up
    • Financing
    • Service and Maintenance Plans
Book Online
801-396-0019
Eco Home Heating and Cooling Experts
Call Now
  • Heating
    • Heating Installation
    • Heating Maintenance
    • Heating Repair
    • Furnace
    • Heat Pumps
    • Mini Splits
    • Service and Maintenance Plans
  • Cooling
    • AC Installation
    • AC Maintenance
    • Air Conditioner Repair
    • Heat Pumps
    • Mini Splits
    • Service and Maintenance Plans
  • New Construction
  • Offers
    • No Money Out Of Pocket
    • Free Quote
    • $0 Down 0% Interest
    • $29 Tune Up
    • Financing
    • Service and Maintenance Plans
Book Online

Energy-Efficient Home Improvements

Client-Focused Leadership Skills

  • Categories: Energy-Efficient Home Improvements, HVAC system maintenance

    HVAC Refrigerants Are Changing – Here’s What Utah Homeowners Need To Know

    read more
  • HVAC replacement cost
    Categories: Energy-Efficient Home Improvements

    HVAC Replacement Cost: A Breakdown by System Type

    read more
  • Categories: Energy-Efficient Home Improvements

    Is Furnace Replacement Worth the Investment?

    read more
  • energy-efficient home improvements
    Categories: Energy-Efficient Home Improvements

    6 Energy-Efficient Home Improvements That Lower Your Utility Bills

    read more
  • hvac system upgrade
    Categories: Energy-Efficient Home Improvements

    6 Signs It’s Time for an HVAC System Upgrade

    read more

Contact

Solar

HVAC

Blog

Privacy Policy

Page load link
Go to Top