Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(drift): Add custom fastland Drift script #347

Closed
15 changes: 12 additions & 3 deletions blocks/marketo/marketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@
return script;
};

const embedMarketoForm = (marketoId, formId, successUrl) => {
const embedMarketoForm = (marketoId, formId, successUrl, driftCampaignID, fastlaneEnable) => {
if (formId && marketoId) {
const mktoScriptTag = loadScript('//go.merative.com/js/forms2/js/forms2.min.js');
mktoScriptTag.onload = () => {
if (successUrl) {
if (successUrl) {

Check failure on line 27 in blocks/marketo/marketo.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 5
window.MktoForms2.loadForm('//go.merative.com', `${marketoId}`, formId, (form) => {
// Add an onSuccess handler
// eslint-disable-next-line no-unused-vars
form.onSuccess((values, followUpUrl) => {
// Adding drift script for chatbot
if (fastlaneEnable) {
drift.api.collectFormData(values, {
campaignId: Number(driftCampaignID),
followupUrl: '/thank-you',
});
}
// Take the lead to a different page on successful submit,
// ignoring the form's configured followUpUrl
location.href = successUrl;
Expand Down Expand Up @@ -83,6 +90,8 @@
const formTitle = blockConfig['form-title'];
const formId = blockConfig['form-id'];
const successUrl = blockConfig['success-url'];
const driftCampaignID = blockConfig['drift-campaign-id'];
const fastlaneEnable = JSON.parse(blockConfig['fastlane-enable'] || false);

if (formId && marketoId) {
// Create the form element
Expand All @@ -103,7 +112,7 @@
const observer = new IntersectionObserver((entries) => {
if (entries.some((e) => e.isIntersecting)) {
// Embed the Marketo form
embedMarketoForm(marketoId, formId, successUrl);
embedMarketoForm(marketoId, formId, successUrl, driftCampaignID, fastlaneEnable);
observer.disconnect();
}
});
Expand Down
Loading