mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-03 09:58:30 +02:00
no need for hubspot API call (#1893)
This commit is contained in:
@@ -43,38 +43,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createOrUpdateHubSpotContact(userEmail, hubspotutk, additionalProperties = {}) {
|
|
||||||
const hubspotPortalId = '139603372';
|
|
||||||
const hubspotFormId = 'a4c7d442-5dcf-4ed2-b71d-df47f99eca27';
|
|
||||||
|
|
||||||
let url = `https://api.hsforms.com/submissions/v3/integration/submit/${hubspotPortalId}/${hubspotFormId}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({
|
|
||||||
fields: [
|
|
||||||
{ name: 'email', value: userEmail },
|
|
||||||
...Object.keys(additionalProperties).map(key => ({
|
|
||||||
name: key,
|
|
||||||
value: additionalProperties[key]
|
|
||||||
}))
|
|
||||||
],
|
|
||||||
context: { hutk: hubspotutk }
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('message', (event) => {
|
window.addEventListener('message', (event) => {
|
||||||
// Normalize event data
|
// Normalize event data
|
||||||
const msg = typeof event.data === 'string' ? { type: event.data } : (event.data || {});
|
const msg = typeof event.data === 'string' ? { type: event.data } : (event.data || {});
|
||||||
@@ -82,22 +50,14 @@
|
|||||||
|
|
||||||
// Hubspot
|
// Hubspot
|
||||||
try {
|
try {
|
||||||
if (email) {
|
if (email) {
|
||||||
const hubspotutk = getCookie(HUBSPOTUTK_COOKIE_NAME);
|
window._hsq = window._hsq || [];
|
||||||
const properties = {
|
window._hsq.push(['identify', { email }]);
|
||||||
hubspot_destination_mapping___segment: `Upsert Contact - Marketing - Frontend`
|
|
||||||
};
|
|
||||||
|
|
||||||
createOrUpdateHubSpotContact(email, hubspotutk, properties)
|
if (sessionStorage.getItem(HS_PAGEVIEWED_NAME) !== 'true') {
|
||||||
.then((res) => {
|
window._hsq.push(['trackPageView']);
|
||||||
window._hsq = window._hsq || [];
|
sessionStorage.setItem(HS_PAGEVIEWED_NAME, 'true');
|
||||||
window._hsq.push(['identify', { email }]);
|
}
|
||||||
|
|
||||||
if (sessionStorage.getItem(HS_PAGEVIEWED_NAME) !== 'true') {
|
|
||||||
window._hsq.push(['trackPageView']);
|
|
||||||
sessionStorage.setItem(HS_PAGEVIEWED_NAME, 'true');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user