From 47165aa7d803c9aa4ec6559a26509bd57898cfd0 Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:13:32 +0530 Subject: [PATCH 1/7] Testing drift code 1 --- blocks/marketo/marketo.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index f51a7d94..e4f19d32 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -28,6 +28,11 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { window.MktoForms2.loadForm('//go.merative.com', `${marketoId}`, formId, (form) => { // Add an onSuccess handler // eslint-disable-next-line no-unused-vars + // drift.on('ready', function (api) { + // api.commitFormData({ + // campaignId: 2787244 + // }); + // }); form.onSuccess((values, followUpUrl) => { // Take the lead to a different page on successful submit, // ignoring the form's configured followUpUrl @@ -37,11 +42,22 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { formName: document.title, }); } + drift.on('ready', function (api) { + console.log('drift'); + try { + api.commitFormData({ + campaignId: 2787244 + }); + } catch (error) { + console.error('Error committing form data to Drift:', error); + } + }); // Drift popup custom code drift.api.collectFormData(values, { campaignId: 2787244, // followupUrl: 'https://www.merative.com/thank-you', followupUrl: successUrl, + stageData: true }); // Return false to prevent the submission handler continuing with its own processing return false; From 79d9dcfd6b09c9fd75c5004703f30bfd170b18c6 Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:52:31 +0530 Subject: [PATCH 2/7] Added Drift ready code --- blocks/marketo/marketo.js | 57 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index e4f19d32..0460b7c1 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -27,38 +27,35 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { if (successUrl) { window.MktoForms2.loadForm('//go.merative.com', `${marketoId}`, formId, (form) => { // Add an onSuccess handler - // eslint-disable-next-line no-unused-vars - // drift.on('ready', function (api) { - // api.commitFormData({ - // campaignId: 2787244 - // }); - // }); - form.onSuccess((values, followUpUrl) => { - // Take the lead to a different page on successful submit, - // ignoring the form's configured followUpUrl - // location.href = successUrl; - if (window._satellite) { - _satellite.track('formSubmit', { - formName: document.title, + form.onSuccess((values) => { + // Drift API call to commit form data immediately upon form submit + if (typeof drift !== 'undefined') { + drift.on('ready', (api) => { + try { + api.commitFormData({ + campaignId: 2787244, + }); + + // Drift popup custom code + drift.api.collectFormData(values, { + campaignId: 2787244, + followupUrl: successUrl, + stageData: true, + }); + + // Adobe Launch tracking for form submission + if (window._satellite) { + _satellite.track('formSubmit', { + formName: document.title, + }); + } + } catch (error) { + console.error('Error with Drift API calls:', error); + } }); + } else { + console.error('Drift is not defined'); } - drift.on('ready', function (api) { - console.log('drift'); - try { - api.commitFormData({ - campaignId: 2787244 - }); - } catch (error) { - console.error('Error committing form data to Drift:', error); - } - }); - // Drift popup custom code - drift.api.collectFormData(values, { - campaignId: 2787244, - // followupUrl: 'https://www.merative.com/thank-you', - followupUrl: successUrl, - stageData: true - }); // Return false to prevent the submission handler continuing with its own processing return false; }); From c8188447625a38395d47a949f31038710e73f37c Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:51:59 +0530 Subject: [PATCH 3/7] Added location condition --- blocks/marketo/marketo.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index 0460b7c1..850e20c4 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -29,6 +29,7 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { // Add an onSuccess handler form.onSuccess((values) => { // Drift API call to commit form data immediately upon form submit + console.log(location.href); if (typeof drift !== 'undefined') { drift.on('ready', (api) => { try { @@ -36,12 +37,14 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { campaignId: 2787244, }); - // Drift popup custom code - drift.api.collectFormData(values, { - campaignId: 2787244, - followupUrl: successUrl, - stageData: true, - }); + if (location.href.includes('/contact')) { + // Drift popup custom code + drift.api.collectFormData(values, { + campaignId: 2787244, + followupUrl: successUrl, + stageData: true, + }); + } else { } // Adobe Launch tracking for form submission if (window._satellite) { From c30dfc5368a4d8174d004c2d2de8ca17051be58c Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:34:09 +0530 Subject: [PATCH 4/7] Fixed lint issue --- blocks/marketo/marketo.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index 850e20c4..8337b550 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -29,7 +29,6 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { // Add an onSuccess handler form.onSuccess((values) => { // Drift API call to commit form data immediately upon form submit - console.log(location.href); if (typeof drift !== 'undefined') { drift.on('ready', (api) => { try { @@ -44,7 +43,7 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { followupUrl: successUrl, stageData: true, }); - } else { } + } // Adobe Launch tracking for form submission if (window._satellite) { @@ -53,11 +52,11 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { }); } } catch (error) { - console.error('Error with Drift API calls:', error); + // console.error('Error with Drift API calls:', error); } }); } else { - console.error('Drift is not defined'); + // console.error('Drift is not defined'); } // Return false to prevent the submission handler continuing with its own processing return false; From e0f3113dc63183980c08c0f8873e7e2ace4bf971 Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:52:56 +0530 Subject: [PATCH 5/7] Removed Drift code --- blocks/marketo/marketo.js | 62 +++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index 8337b550..3e078b43 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -27,37 +27,43 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { if (successUrl) { window.MktoForms2.loadForm('//go.merative.com', `${marketoId}`, formId, (form) => { // Add an onSuccess handler - form.onSuccess((values) => { + form.onSuccess(() => { + location.href = successUrl; + if (window._satellite) { + _satellite.track('formSubmit', { + formName: document.title, + }); + } // Drift API call to commit form data immediately upon form submit - if (typeof drift !== 'undefined') { - drift.on('ready', (api) => { - try { - api.commitFormData({ - campaignId: 2787244, - }); + // if (typeof drift !== 'undefined') { + // drift.on('ready', (api) => { + // try { + // api.commitFormData({ + // campaignId: 2787244, + // }); - if (location.href.includes('/contact')) { - // Drift popup custom code - drift.api.collectFormData(values, { - campaignId: 2787244, - followupUrl: successUrl, - stageData: true, - }); - } + // if (location.href.includes('/contact')) { + // // Drift popup custom code + // drift.api.collectFormData(values, { + // campaignId: 2787244, + // followupUrl: successUrl, + // stageData: true, + // }); + // } - // Adobe Launch tracking for form submission - if (window._satellite) { - _satellite.track('formSubmit', { - formName: document.title, - }); - } - } catch (error) { - // console.error('Error with Drift API calls:', error); - } - }); - } else { - // console.error('Drift is not defined'); - } + // // Adobe Launch tracking for form submission + // if (window._satellite) { + // _satellite.track('formSubmit', { + // formName: document.title, + // }); + // } + // } catch (error) { + // // console.error('Error with Drift API calls:', error); + // } + // }); + // } else { + // // console.error('Drift is not defined'); + // } // Return false to prevent the submission handler continuing with its own processing return false; }); From b91dd1390b467d9aa147ca52db7d73e0d4157364 Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Fri, 2 Aug 2024 18:57:48 +0530 Subject: [PATCH 6/7] Uncommeted Drift Code --- blocks/marketo/marketo.js | 66 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index 3e078b43..d5b437df 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -28,42 +28,42 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { window.MktoForms2.loadForm('//go.merative.com', `${marketoId}`, formId, (form) => { // Add an onSuccess handler form.onSuccess(() => { - location.href = successUrl; - if (window._satellite) { - _satellite.track('formSubmit', { - formName: document.title, - }); - } + // location.href = successUrl; + // if (window._satellite) { + // _satellite.track('formSubmit', { + // formName: document.title, + // }); + // } // Drift API call to commit form data immediately upon form submit - // if (typeof drift !== 'undefined') { - // drift.on('ready', (api) => { - // try { - // api.commitFormData({ - // campaignId: 2787244, - // }); + if (typeof drift !== 'undefined') { + drift.on('ready', (api) => { + try { + api.commitFormData({ + campaignId: 2787244, + }); - // if (location.href.includes('/contact')) { - // // Drift popup custom code - // drift.api.collectFormData(values, { - // campaignId: 2787244, - // followupUrl: successUrl, - // stageData: true, - // }); - // } + if (location.href.includes('/contact')) { + // Drift popup custom code + drift.api.collectFormData(values, { + campaignId: 2787244, + followupUrl: successUrl, + stageData: true, + }); + } - // // Adobe Launch tracking for form submission - // if (window._satellite) { - // _satellite.track('formSubmit', { - // formName: document.title, - // }); - // } - // } catch (error) { - // // console.error('Error with Drift API calls:', error); - // } - // }); - // } else { - // // console.error('Drift is not defined'); - // } + // Adobe Launch tracking for form submission + if (window._satellite) { + _satellite.track('formSubmit', { + formName: document.title, + }); + } + } catch (error) { + console.error('Error with Drift API calls:', error); + } + }); + } else { + console.error('Drift is not defined'); + } // Return false to prevent the submission handler continuing with its own processing return false; }); From cf2a50d96ec2251cf76792c749cd8c50a9019ad1 Mon Sep 17 00:00:00 2001 From: Kanaksinh <163413435+raj-bluetext@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:19:36 +0530 Subject: [PATCH 7/7] Updated Playbook logic --- blocks/marketo/marketo.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/blocks/marketo/marketo.js b/blocks/marketo/marketo.js index d5b437df..5e836201 100644 --- a/blocks/marketo/marketo.js +++ b/blocks/marketo/marketo.js @@ -58,11 +58,17 @@ const embedMarketoForm = (marketoId, formId, successUrl) => { }); } } catch (error) { - console.error('Error with Drift API calls:', error); + console.log('Error with Drift API calls:', error); } }); } else { - console.error('Drift is not defined'); + console.log('Drift is not defined'); + location.href = successUrl; + if (window._satellite) { + _satellite.track('formSubmit', { + formName: document.title, + }); + } } // Return false to prevent the submission handler continuing with its own processing return false;