Skip to content

Commit

Permalink
Added Drift ready code
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-bluetext committed Jun 4, 2024
1 parent 47165aa commit 79d9dcf
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions blocks/marketo/marketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 53 in blocks/marketo/marketo.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
}
});
} else {
console.error('Drift is not defined');

Check warning on line 57 in blocks/marketo/marketo.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
}
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;
});
Expand Down

0 comments on commit 79d9dcf

Please sign in to comment.