How Lantern wires HubSpot Forms to capture ai_source, ai_engine, and ai_prompt on every submission — including hidden field setup that survives page refreshes and cross-domain embeds.
HubSpot Forms are where most contacts are actually created. If AI source data isn't captured at form submit, you lose attribution for the single most important event in the funnel. Lantern configures three hidden fields (ai_source, ai_engine, ai_prompt) on every HubSpot form, pre-populates them from the first-party cookie Lantern set on landing, and validates the values against the AI engine allowlist.
The configuration is automatic for forms embedded via HubSpot's standard embed snippet — Lantern's JS intercepts form init, injects the hidden fields, and pre-populates values from lantern_ai_src cookie. For forms embedded via the raw HubSpot API (common in React/Vue apps), you add two lines of code. Lantern's customer-success docs include copy-paste React and Vue wrappers.
For standard HubSpot embedded forms: nothing to do. Lantern's snippet wires the hidden fields automatically. For React/Next.js apps using the HubSpot Forms API (hbspt.forms.create): add an onFormReady callback that calls the Lantern helper function. For non-HubSpot forms that post to HubSpot (custom API calls): include the ai_source, ai_engine, ai_prompt fields in the contact properties payload.
// React component: HubSpot form with AEO source tracking
import { useEffect, useRef } from 'react';
export function HubSpotForm({ portalId, formId }) {
const formRef = useRef(null);
useEffect(() => {
const script = document.createElement('script');
script.src = '//js.hsforms.net/forms/v2.js';
script.onload = () => {
window.hbspt.forms.create({
portalId,
formId,
target: '#hubspot-form-container',
onFormReady: (form) => {
// Lantern AEO hidden field injection
const aiSrc = window.Lantern?.getAISource() || '';
const aiEngine = window.Lantern?.getAIEngine() || '';
const aiPrompt = window.Lantern?.getAIPrompt() || '';
// Append hidden inputs
const form$ = form[0];
['ai_source', 'ai_engine', 'ai_prompt'].forEach((name, i) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = [aiSrc, aiEngine, aiPrompt][i];
form$.appendChild(input);
});
}
});
};
document.head.appendChild(script);
}, [portalId, formId]);
return <div id="hubspot-form-container" ref={formRef} />;
}This page describes one specific surface inside HubSpot where Lantern's AEO pipeline attribution plugs in. The full integration stitches together across HubSpot Contacts, Deals, Workflows, Lists, Reports, Forms, CMS, and the Marketing/Sales/Service Hub stack. If you're evaluating where to start, the comparison hub has side-by-side comparisons of Lantern against Profound, Scrunch, Peec AI, AthenaHQ, and HubSpot's own AEO product — scored on the dimensions that matter for a CMO buyer (CRM integration depth, reporting quality, prompt-scaling economics).
If you're about to walk this work into a renewal review or budget conversation, the CFO's Guide to AEO Budget Defense has the memo template, the five-slide deck structure, the attribution-math cheat sheet, and the three most-common CFO objections with counter-arguments. It's the long-form companion that translates the technical HubSpot setup on this page into a defensible dollar number for finance.
Instead of hand-wiring properties, workflows, and tracking snippets, Lantern installs the full HubSpot integration in under 30 minutes — then ships the monthly AEO pipeline ROI report your CFO signs off on. $99/mo Starter or Enterprise. 14-day free trial.
Start free trial