Discovery iframe events
Listen to what visitors do inside an embedded Discovery page (leads, reservations, favorites, page views) from your own site.
When a Discovery page is shown inside an <iframe> (see
Embed Discovery in your site), it tells the page that embeds
it what the visitor does: a lead sent, a lot reserved, a favorite saved, a
page viewed. Your site can listen for these events and act on them, for
example by sending them to your own analytics, creating a contact in your
CRM, or opening a chat.
Events are sent with
window.postMessage.
They go one way, from Discovery to your page. They are only sent when the page
is inside an iframe, never when someone opens it directly.
Quick start
<iframe
src="https://discovery.acantera.com/<organization>/<community>/masterplan?embed"
style="width: 100%; height: 100vh; border: 0"
allow="fullscreen; clipboard-write"
></iframe>
<script>
const DISCOVERY_ORIGIN = "https://discovery.acantera.com";
window.addEventListener("message", (event) => {
// Only trust messages from Discovery itself.
if (event.origin !== DISCOVERY_ORIGIN) return;
const message = event.data;
if (message?.source !== "acantera:discovery") return;
switch (message.type) {
case "lead.submitted":
gtag("event", "generate_lead", { lead_id: message.payload.leadId });
break;
case "reservation.confirmed":
gtag("event", "purchase", { transaction_id: message.payload.reservationId });
break;
}
});
</script>Add the listener before the iframe loads (put the script above the iframe, or
set the iframe's src after adding it). Otherwise you can miss ready.
Choose which events are sent
All events are sent by default. The iframe's ?events= parameter narrows
them down:
events | Sends |
|---|---|
not set, bare, *, all | Every event (the default). |
none, off, false, 0 | No events. |
comma list, e.g. lead.*,reservation.* | Only these. Each entry is an exact type (lead.submitted), a namespace (reservation.*) or *. |
…/masterplan?embed&events=lead.submitted,reservation.* …/modelos?embed&model=casa-roble&events=none
ready is sent under any list, so you can always tell the frame loaded. Only
events=none stops it. The setting is read once, from the address the iframe
loads with, and is kept as the visitor moves around the community.
Message format
Every message has the same envelope:
type DiscoveryMessage = {
source: "acantera:discovery";
version: 1;
type: string; // one of the event types below
payload: object; // depends on `type`
community: { id: string; slug: string } | null;
timestamp: string; // ISO 8601
};version changes only for a breaking change: a field renamed or removed, or
an event's meaning changed. New event types and new payload fields can be
added at any time without a version bump, so ignore types and fields you don't
know.
Shared shapes
type Lot = {
id: string;
name: string; // e.g. "Lote 002"
status: string | null; // "available", "reserved", "sold", …
price: number | null; // total price; null when not published
};
type Model = { id: string; name: string };
// A plan of the master plan: the site plan, or a sub-plan to drill into.
type View = { id: string; name: string; kind: "site" | "phase" | "zone" | "building" | "floor" };
type Item = {
type: "inventory" | "model"; // a lot, or a model (floor plan)
id: string;
name: string | null;
};
type Page = "home" | "masterplan" | "models" | "amenities" | "galleries" | "location" | "brochure";
// A payment plan, with what it comes to for the lot's price.
type PaymentPlan = {
id: string;
name: string; // e.g. "12 meses sin intereses"
monthlyInstallments: number; // 0 for a contado plan
monthlyPayment: number | null; // the first monthly payment; null for contado
finalPrice: number; // the lot's price after the plan's discount or surcharge
totalPaid: number; // everything paid: final price plus any opening fee and interest
};Events
Lifecycle
| Type | When | Payload |
|---|---|---|
ready | The community page loaded. Sent once, before any other event. | { organization: { slug }, community: { id, slug, name }, page: Page, embedded: boolean } |
page.viewed | A page was shown, starting with the first one (right after ready). | { page: Page, path: string } |
Conversion
| Type | When | Payload |
|---|---|---|
lead.submitted | A lead form was sent and the lead was created. | { leadId, form: "contact" | "favorites", interests: Item[], broker: string | null } |
reservation.started | The visitor opened the "Reservar ahora" flow of an available lot. | { lot: Lot } |
reservation.code_sent | A verification code was emailed. resent is true when they asked for another one. | { lot: Lot, resent: boolean } |
reservation.confirmed | The code checked out and the lot is reserved for the lead. | { lot: Lot, leadId: string | null, reservationId: string } |
reservation.cancelled | The visitor closed the flow before confirming. | { lot: Lot, step: "details" | "code" } |
contact.clicked | A broker contact button (WhatsApp, phone, email) was clicked on the visitor's brochure. | { channel: "whatsapp" | "phone" | "email", broker: { name } } |
form tells you which form was used: contact is the form at the end of the
home page, and favorites is the "Recibe tu brochure" form in the favorites
panel.
Favorites
| Type | When | Payload |
|---|---|---|
favorite.added | A lot or model was liked. | { item: Item, count: number } |
favorite.removed | A lot or model was unliked. | { item: Item, count: number } |
count is how many favorites the visitor has after the change.
Browsing
| Type | When | Payload |
|---|---|---|
lot.selected | A lot was selected on the master plan, from the plan, the list or ?item=. viewId is the plan it's on. | { lot: Lot, viewId: string | null } |
lot.cleared | The master plan selection was cleared. | {} |
view.changed | The master plan moved to another plan: into a sub-plan (a phase, a building, a floor) or back up, including landing on one from ?view=. path runs from the site plan down to view. | { view: View, path: View[] } |
model.viewed | A model is shown on the models page, starting with the first one. | { model: Model } |
model.view_changed | The model viewer switched between photos, floor plans and the virtual tour. | { model: Model, view: "photos" | "plans" | "tour" } |
gallery.opened | A gallery opened full screen, from a master plan point of interest or the galleries page. | { gallery: { id, name }, context: "masterplan" | "galleries" } |
document.opened | A lot's technical sheet was opened. | { kind: "technical_sheet", lot: Lot } |
filters.applied | The master plan's inventory filters changed. Sent once the visitor stops adjusting them. Statuses are ids; types is deprecated and always empty (inventory types were removed); ranges are [min, max] or null when unset. | { statuses, types, kinds, blocks, buildings: string[], price, size: [number, number] | null } |
floorplan.opened | A model's floor plan was opened from a lot's detail on the master plan. | { model: Model, lot: Lot | null } |
amenity.opened | An amenity's photo was opened full screen on the amenities page. | { amenity: { id, name } } |
location.point_selected | A nearby place was selected on the location page, from the list or the map. | { point: { id, name } } |
location.tour_started | The guided tour of nearby places started. | { stops: number } |
plan.tour_started | The guided tour of a plan's points of interest started, by hand or from ?guide=on: on the master plan (view is null on a legacy site plan) or a model's floor plans. | { context: "masterplan", view: View | null, stops: number } | { context: "model", model: Model, stops: number } |
brochure.viewed | A lead opened their personal brochure. | { leadId: string } |
Payment plans
A lot's details on the master plan can show its community's payment plans,
when your organization uses them. All four events share the payment_plan.* namespace.
| Type | When | Payload |
|---|---|---|
payment_plan.opened | The visitor opened "Ver planes de pago" on a lot. plan is the one shown first (the one they marked, else the first); plans is how many there are. | { lot: Lot, plan: PaymentPlan, plans: number } |
payment_plan.selected | Another plan was picked in the lot's calculator. | { lot: Lot, plan: PaymentPlan } |
payment_plan.favorited | The visitor marked the plan they'd pay the lot with (the heart). One per lot; marking another replaces it. | { lot: Lot, plan: PaymentPlan } |
payment_plan.unfavorited | The visitor took the heart off the lot's plan. | { lot: Lot, plan: PaymentPlan } |
Marking a plan also saves the lot, so a favorite.added follows when the lot
wasn't saved yet. The marked plans are sent with the lead form apart from
interests.
Hover and scroll are not reported. They are too frequent to be useful.
Example messages
{
"source": "acantera:discovery",
"version": 1,
"type": "reservation.confirmed",
"payload": {
"lot": {
"id": "01M0JF8E7SNAKGB39SR0T21F9H",
"name": "Lote 002",
"status": "available",
"price": 381600
},
"leadId": "01M7ZSYJPHTY9TENZMN9K4V8ED",
"reservationId": "01M7ZT3Q1V0K8D2X5F7H9JBCNA"
},
"community": { "id": "01M0GVAGJKXWEB072DC2RX99BC", "slug": "corregidora" },
"timestamp": "2026-11-21T19:02:11.481Z"
}lot.status is the status when the visitor opened the flow. After a confirmed
reservation, the lot shows as reserved in Discovery.
Privacy and security
- No contact details. Payloads never include the visitor's name, email or
phone. Use
leadIdto look up the lead in Acantera, where the data is under your organization's access rules. - Check
event.originagainsthttps://discovery.acantera.combefore you use a message. Any frame on your page can callpostMessage. - The lead's browsing timeline. Separately from these messages, Discovery
keeps the same interactions in the page's memory and sends them to Acantera
only with the lead form, so your brokers see how the lead got there in the
lead's timeline in Studio. Nothing is stored on the visitor's device or sent
before the form, and nothing is kept after it.
?events=doesn't change it; Global Privacy Control and Do Not Track turn it off. - Discovery posts with target origin
*, because it can't know ahead of time which site embeds it. This is why payloads are limited to ids, names and statuses.
TypeScript
You can copy these types into your own code:
type Lot = { id: string; name: string; status: string | null; price: number | null };
type Model = { id: string; name: string };
type View = { id: string; name: string; kind: "site" | "phase" | "zone" | "building" | "floor" };
type Item = { type: "inventory" | "model"; id: string; name: string | null };
type Page = "home" | "masterplan" | "models" | "amenities" | "galleries" | "location" | "brochure";
type PaymentPlan = {
id: string;
name: string;
monthlyInstallments: number;
monthlyPayment: number | null;
finalPrice: number;
totalPaid: number;
};
type DiscoveryEvents = {
ready: {
organization: { slug: string };
community: { id: string; slug: string; name: string };
page: Page;
embedded: boolean;
};
"page.viewed": { page: Page; path: string };
"favorite.added": { item: Item; count: number };
"favorite.removed": { item: Item; count: number };
"lead.submitted": {
leadId: string;
form: "contact" | "favorites";
interests: Item[];
broker: string | null;
};
"reservation.started": { lot: Lot };
"reservation.code_sent": { lot: Lot; resent: boolean };
"reservation.confirmed": { lot: Lot; leadId: string | null; reservationId: string };
"reservation.cancelled": { lot: Lot; step: "details" | "code" };
"lot.selected": { lot: Lot; viewId: string | null };
"lot.cleared": Record<string, never>;
"view.changed": { view: View; path: View[] };
"model.viewed": { model: Model };
"model.view_changed": { model: Model; view: "photos" | "plans" | "tour" };
"gallery.opened": { gallery: { id: string; name: string }; context: "masterplan" | "galleries" };
"document.opened": { kind: "technical_sheet"; lot: Lot };
"filters.applied": {
statuses: string[];
types: string[]; // deprecated, always empty
kinds: string[];
blocks: string[];
buildings: string[];
price: [number, number] | null;
size: [number, number] | null;
};
"floorplan.opened": { model: Model; lot: Lot | null };
"amenity.opened": { amenity: { id: string; name: string } };
"location.point_selected": { point: { id: string; name: string } };
"location.tour_started": { stops: number };
"plan.tour_started":
| { context: "masterplan"; view: View | null; stops: number }
| { context: "model"; model: Model; stops: number };
"payment_plan.opened": { lot: Lot; plan: PaymentPlan; plans: number };
"payment_plan.selected": { lot: Lot; plan: PaymentPlan };
"payment_plan.favorited": { lot: Lot; plan: PaymentPlan };
"payment_plan.unfavorited": { lot: Lot; plan: PaymentPlan };
"brochure.viewed": { leadId: string };
"contact.clicked": { channel: "whatsapp" | "phone" | "email"; broker: { name: string } };
};
type DiscoveryMessage = {
[T in keyof DiscoveryEvents]: {
source: "acantera:discovery";
version: 1;
type: T;
payload: DiscoveryEvents[T];
community: { id: string; slug: string } | null;
timestamp: string;
};
}[keyof DiscoveryEvents];