diff --git a/website/api/controllers/deliver-talk-to-us-form-submission.js b/website/api/controllers/deliver-talk-to-us-form-submission.js index 076b9977f1..8e835b5325 100644 --- a/website/api/controllers/deliver-talk-to-us-form-submission.js +++ b/website/api/controllers/deliver-talk-to-us-form-submission.js @@ -66,7 +66,10 @@ module.exports = { }, success: { decription: 'A user successfully submitted the "Talk to us" form.', - outputType: 'string', + outputType: { + icp: 'boolean', + eventUrl: 'string', + }, } }, @@ -85,22 +88,26 @@ module.exports = { lastName: lastName, // organization: organization, // Note: the user-provided organization is not used here because we're relying on the enrichment helper below to find the correct organization for this person. primaryBuyingSituation: primaryBuyingSituation === 'security-misc' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'it-misc' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'it-major-mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'it-gap-filler-mdm' ? 'IT - Gap-filler MDM' : primaryBuyingSituation === 'security-vm' ? 'Vulnerability management' : undefined, - contactSource: 'Website - Contact forms', psychologicalStage: '4 - Has use case', psychologicalStageChangeReason: 'Website - Contact forms' }; // If the user said they have 700+ hosts, Update/create a contact and account, and send them to the "Talk to us" Calendly event. if(numberOfHosts >= 700){ + contactInformation.contactSource = 'Website - Contact forms - Demo - ICP'; contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Talk to us" event. Provided organization name: ${organization}, Number of hosts: ${numberOfHosts}`; sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{ if(err) { sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err); } }); - return `https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`; + return { + icp: true, + eventUrl: `https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}` + }; } else { // If the user has <700 hosts, use the get-enriched helper to try to find the number of employees at their organization. + let enrichmentInformation = await sails.helpers.iq.getEnriched.with({ emailAddress, firstName, @@ -112,22 +119,30 @@ module.exports = { // If we got a employer.numberOfEmployees value from the getEnriched helper, send the user to the "talk to us" calendly event if it is 700+. if(enrichmentInformation.employer && enrichmentInformation.employer.numberOfEmployees && enrichmentInformation.employer.numberOfEmployees >= 700) { + contactInformation.contactSource = 'Website - Contact forms - Demo - ICP'; contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Talk to us" event because of the number of employees (${enrichmentInformation.employer.numberOfEmployees}) returned by Coresignal. Provided organization name: ${organization}, Number of hosts: ${numberOfHosts}`; sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{ if(err) { sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err); } }); - return `https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`; + return { + icp: true, + eventUrl:`https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}` + }; } else { - // If the enrichment helper didn't return a employer.numberOfEmployees value and this user has <700 hosts, send them to the "Let's get you set up!" Calendly event + // If the enrichment helper didn't return a employer.numberOfEmployees value and this user has <700 hosts, send them to the "Let's get you set up!" Calendly event + contactInformation.contactSource = 'Website - Contact forms - Demo'; contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Let\'s get you set up!" event. Provided organization name: ${organization}, Number of hosts: ${numberOfHosts}`; sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{ if(err) { sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err); } }); - return `https://calendly.com/fleetdm/chat?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`; + return { + icp: false, + eventUrl: `https://calendly.com/fleetdm/chat?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}` + }; } } } diff --git a/website/api/helpers/salesforce/update-or-create-contact-and-account.js b/website/api/helpers/salesforce/update-or-create-contact-and-account.js index 2f847aab6a..74a0da2746 100644 --- a/website/api/helpers/salesforce/update-or-create-contact-and-account.js +++ b/website/api/helpers/salesforce/update-or-create-contact-and-account.js @@ -39,6 +39,8 @@ module.exports = { type: 'string', isIn: [ 'Website - Contact forms', + 'Website - Contact forms - Demo', + 'Website - Contact forms - Demo - ICP', 'Website - Sign up', 'Website - Newsletter', 'LinkedIn - Comment', diff --git a/website/assets/js/pages/contact.page.js b/website/assets/js/pages/contact.page.js index 9c8c81b4b8..3d9fab9fce 100644 --- a/website/assets/js/pages/contact.page.js +++ b/website/assets/js/pages/contact.page.js @@ -97,15 +97,21 @@ parasails.registerPage('contact', { }, handleSubmittingTalkToUsForm: async function(argins) { this.syncing = true; - if(typeof gtag !== 'undefined'){ - gtag('event','fleet_website__contact_forms'); - } if(typeof window.lintrk !== 'undefined') { window.lintrk('track', { conversion_id: 18587089 });// eslint-disable-line camelcase } - let eventUrl = await Cloud.deliverTalkToUsFormSubmission.with(argins); + let report = await Cloud.deliverTalkToUsFormSubmission.with(argins); - this.goto(eventUrl); + if(typeof gtag !== 'undefined'){ + // Look at result from talking to api and decide what event to track. + if(report.icp){ + gtag('event','fleet_website__contact_forms__demo'); + } else { + gtag('event','fleet_website__contact_forms__demo__icp'); + } + } + + this.goto(report.eventUrl); }, clickSwitchForms: function(form) {