Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6710,7 +6710,7 @@ <h5>contact</h5>
const meta = document.querySelector('meta[name="iii:mailmodo-form-url"]');
return meta && meta.getAttribute('content') ? meta.getAttribute('content').trim() : '';
}
async function submitToMailmodo(email){
async function submitToMailmodo(email, formLocation){
const url = getMailmodoFormUrl();
if (!url) return;
try {
Expand All @@ -6722,6 +6722,7 @@ <h5>contact</h5>
// Mailmodo returns 409 for already-subscribed; treat as success.
if (!res.ok && res.status !== 409) throw new Error('mailmodo submission failed');
if (typeof window.iiiNotifyCommonRoomEmail === 'function') window.iiiNotifyCommonRoomEmail(email);
if (typeof window.iiiNotifyPostHogEmailSubmit === 'function') window.iiiNotifyPostHogEmailSubmit(email, formLocation);
} catch (_) {
// Swallow — we still mark the form submitted so users aren't blocked.
}
Expand Down Expand Up @@ -6750,7 +6751,7 @@ <h5>contact</h5>
persistAccessRequest(v);
emailForm.classList.add('submitted');
emailInput.value = '';
submitToMailmodo(v);
submitToMailmodo(v, 'hero');
});
}

Expand Down Expand Up @@ -7104,7 +7105,7 @@ <h5>contact</h5>
persistAccessRequest(v);
form.classList.add('submitted');
input.value = '';
submitToMailmodo(v);
submitToMailmodo(v, 'footer');
});
})();

Expand Down
30 changes: 30 additions & 0 deletions website/posthog-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@
});
};

// Records a successful email-form submission in PostHog. We identify() the
// person by their email (the cross-system key Common Room also de-anonymizes
// on), which creates the PostHog person profile under
// person_profiles: 'identified_only'. Where Common Room's signals-sdk-user-id
// cookie is already present we attach its visitor id too, so the two systems
// can be joined per visitor; if it isn't set yet we just record without it.
function iiiReadCommonRoomId() {
var match = document.cookie.match(/(?:^|;\s*)signals-sdk-user-id=([^;]+)/);
return match ? decodeURIComponent(match[1]) : null;
}

window.iiiNotifyPostHogEmailSubmit = function (email, formLocation) {
try {
if (localStorage.getItem(STORAGE_KEY) !== 'accepted') return;
if (!window.posthog || typeof window.posthog.capture !== 'function') return;
var crId = iiiReadCommonRoomId();
var distinctId = email || crId;
if (distinctId) {
var personProps = {};
if (email) personProps.email = email;
if (crId) personProps.common_room_user_id = crId;
window.posthog.identify(distinctId, personProps);
}
var props = { form_location: formLocation || 'unknown' };
if (email) props.email = email;
if (crId) props.common_room_user_id = crId;
window.posthog.capture('website_email_submit', props);
} catch (_) {}
};

try {
if (localStorage.getItem(STORAGE_KEY) === 'accepted') window.iiiLoadPostHog();
} catch (_) {}
Expand Down
Loading