Skip to content
← Back to Systems

Email Intelligence System

How a form submission becomes a Customer Intent Report.

This system captures customer behavior before submission—page path, referrer, device data, engagement metrics, session history, search behavior, and customer actions—then packages that context into a structured lead intelligence email for the business.

The result is a sales-ready report that explains what the customer was doing, what they were interested in, how engaged they were, and what the business should understand before replying.

Next.jsTypeScriptResendsessionStorageGA4Lead MetadataCustomer Intent

The Problem

Traditional forms capture the message but lose the buying context.

A basic form tells the business what the customer typed. It does not explain how they arrived, what they viewed, how long they engaged, what they searched, what CTA they opened, or whether the inquiry came from a casual visitor or a qualified buyer.

Traditional Contact Form

  • • Name
  • • Email
  • • Phone
  • • Message

No context about what the customer was doing before they contacted you.

Customer Intent Report

  • • Name, Email, Phone, Message
  • + Session Path
  • + Search Queries
  • + Clicked Search Results
  • + Customer Actions
  • + Engagement Metrics
  • + Device & Browser Context

Full context: what they searched, what they clicked, how long they browsed.

The question this system answers:

"What was the customer doing before they contacted us?"

System Overview

Three-layer architecture: Collect, Aggregate, Render.

The system tracks customer behavior in the browser, aggregates that data when a form is submitted, and renders it into a structured email report sent to the business owner.

1

Layer 1: Session Behavior Collection

Client-side tracking captures the visitor’s session path, page engagement, scroll depth, time on page, referrer, device context, search behavior, and customer actions.

Tech: React hooks, sessionStorage, engagement tracking, GlobalSearch

2

Layer 2: Form Metadata Assembly

When a customer opens or submits a form, the platform combines the form fields with the behavioral session data collected before submission.

Tech: TypeScript form metadata, source labels, page/form context

3

Layer 3: API Route Processing

The form submission is sent to a Next.js API route, where the message, customer details, source, and metadata are structured into one lead payload.

Tech: Next.js API routes, validation, typed payloads

4

Layer 4: Resend Email Rendering

The Resend email service renders the main submission card and the Customer Intent Report card with Page & Form, Device & Browser, Engagement, Session Path, Search Queries, and Customer Actions.

Tech: Resend, HTML email templates, renderCustomerIntentReport()

5

Layer 5: Business Follow-Up

The business receives more than a contact form. It receives lead context that helps qualify the buyer, understand intent, and respond with the right next step.

Tech: Lead intelligence, sales workflow, operational decision support

Data Captured

What the system tracks during each session.

Page & Form Context

Submitted timestamp, current page, form source, CTA context

Device & Browser

Device type, viewport, browser, referrer, approximate location

Engagement Metrics

Time on page, time on site, scroll depth, interaction depth

Session Path

Ordered page journey before the customer submitted the form

Search Queries

Search term, result count, clicked result, and result position

Customer Actions

Sequential actions such as opened CTA, searched, clicked, submitted

Example Search Query Data

Query: "pinarello dogma"

Results: 12

Clicked: Pinarello Dogma F Dura Ace Di2

Position: 1

Example Customer Actions Timeline

  1. 1. Opened global search
  2. 2. Searched "pinarello dogma"
  3. 3. Clicked "Pinarello Dogma F Dura Ace Di2" (position 1 of 12)
  4. 4. Viewed product page
  5. 5. Navigated to Road Bikes category
  6. 6. Navigated to Bike Fitting page
  7. 7. Submitted fitting inquiry form

Production Example

See the complete Customer Intent Report.

The Systems page shows a full recreation of the Customer Intent Report email with anonymized lead data, including all tracked sections: submission details, device & browser, engagement metrics, session path, search queries, and customer actions.

Customer Intent Report Structure

  • Submission Details: Name, email, phone, subject, message, timestamp
  • Device & Browser: Device type, viewport, browser, referrer, location
  • Engagement: Time on page, time on site, scroll depth
  • Session Path: Ordered list of pages visited
  • Search Queries: Each query with results count, clicked result, position
  • Customer Actions: Sequential behavior timeline
View Complete Example →

Technical Implementation

The production email is generated in two parts.

The first part is the normal customer submission: name, email, phone, subject, and message. The second part is the Customer Intent Report, rendered from the metadata collected before submission.

1. sessionStorage Tracking Strategy

As users navigate the site, JavaScript stores behavioral data in sessionStorage. This includes page views (session path), search queries from the GlobalSearch component, and customer actions like "Opened modal" or "Viewed product page." sessionStorage is frontend-only—no database persistence, no cookies, no external tracking.

2. GlobalSearch Integration

When a user searches the site, the GlobalSearch component captures the query, counts results, and tracks which result was clicked and at what position. This data is stored in sessionStorage as a SearchQuery object with properties: query, results, clickedResult, position.

3. Customer Actions Tracking

Throughout the session, key interactions are logged to a customerActions array in sessionStorage. Examples: "Opened global search", "Searched [query]", "Clicked [product] (position X of Y)", "Viewed product page", "Submitted form". This creates a sequential timeline of customer behavior.

4. API Route Aggregation

When the form is submitted, the API route receives both form data (name, email, message) and sessionStorage data (session path, search queries, customer actions, device metadata). It validates inputs, structures the data into a lead object, and passes it to the email rendering function.

5. resend.ts Report Rendering

The resend.ts file contains a renderCustomerIntentReport() function that takes the lead object and renders HTML email sections: submission card, device/browser, engagement, session path, search queries, and customer actions. The email is sent via Resend to the business owner.

Business Impact

The system turns form submissions into qualified sales context.

Instead of receiving a generic inquiry, the business can see whether the customer came from Google, how long they researched, which page converted them, what product or service they focused on, and what next step is most likely to move the conversation forward.

What the business learns:

  • • Where the lead came from
  • • Which page or CTA converted
  • • How engaged the visitor was
  • • What product, service, or problem they focused on
  • • Whether the follow-up should be sales, fitting, service, or quote focused

What the business can do:

  • • Prioritize high-intent leads faster
  • • Reply with more specific context
  • • Recommend the correct next step
  • • Connect marketing behavior to sales conversations
  • • Feed future dashboard and CRM workflows

Service-Commerce Platform

This is not traditional e-commerce. This is inquiry-based commerce for high-ticket services.

Traditional E-Commerce

Search → Product View → Add to Cart → Checkout → Order

Optimized for self-service transactions. Customer completes purchase without human interaction.

Service-Commerce

Search → Product/Service Intent → Page View → Inquiry → Appointment → Work Order / Sale

Optimized for high-ticket, consultation-based sales. Platform captures intent, business follows up with context.

For Mox Multisport, the real product is not the bike—it's the platform layer that connects search intent, product discovery, customer behavior, and structured lead intelligence into a sales conversation with full context.

Privacy & Data Handling

Frontend-only storage. No database persistence.

sessionStorage (frontend-only)

Behavioral data is stored in the browser's sessionStorage. This is client-side only—it never touches a database, never persists beyond the session, and clears when the browser tab is closed.

No database persistence

The system does not store leads in a database. Form submissions and sessionStorage data are transmitted once to the API route, packaged into an email, and sent to the business owner via Resend.

Email-only transmission

After form submission, the lead data is sent as a structured email to the business owner. The data exists in the email inbox, not in application storage.

Third-party tracking

The site uses Google Analytics for traffic analysis. No additional third-party tracking scripts are used for the Email Intelligence System—all tracking is custom-coded and stays within the application.

Related Systems

Part of the complete Mox Platform architecture.

Production Output

See the Customer Intent Report as the business receives it.

The Systems page shows a recreated production email with the main customer submission and the Customer Intent Report rendered together as a business-facing lead intelligence workflow.

View production example →