Following the initial post in our series on using FlowBoost with Marketo, we now delve into the details of implementing a basic phone number cleaning script. This post is the second of our three part Flowboost series and explores how to leverage Flowboost’s capabilities to clean and standardize phone numbers in your Marketo environment.
As a quick recap, Flowboost is the brainchild of legendary Marketo veterans Sanford Whiteman, and Edward Unthank of Etumos. In this 3 part-series we will go through:
- Part 1: What can Flowboost Do + The basic setup of Flowboost
- Part 2: Using Flowboost for basic phone number data cleaning
- Part 3 [Coming Soon]: Proper capitalisation of First and Last Names value when new persons are created in Marketo + Advantages & Limitations of the Community Edition of Flowboost
This blogpost references many steps from Part 1 of our series, so be sure to take a look and try out what we wrote in Part 1 if you haven’t already, before attempting the steps below.
Get Started
Now as we all know, phone numbers may come in different formats, such as:
- +1 234 567 8901
- 12345678901
- 1-234-567-8901
- 123 456 789 01
Today we’ll go through a simple phone number cleaning script that removes all non-numeric characters from the field values except for leading plus signs for phone numbers containing the country code.
Set-up Process
1. Clone the webhook you created in the first blogpost
Give it an appropriate name that indicates the purpose of the webhook clearly.
2. Edit the payload and replace it with the following:
a. This script removes all non-numeric characters from the field values except for leading plus signs for phone numbers containing the country code.
mobilenumber = {{lead.Mobile Phone Number}};
function removeNonNumericalChars(str) {
// Check for a leading plus sign and store the condition
const hasLeadingPlus = str.startsWith('+');
// Remove all non-numeric characters
let cleanedStr = str.replace(/[^0-9]/g, '');
// Prepend the plus sign if the original string had it
if (hasLeadingPlus) {
cleanedStr = '+' + cleanedStr;
}
return cleanedStr;}
var cleanedMobileNumber = removeNonNumericalChars(mobilenumber);
It should look something like this:
b. You might need to change the tokens to the correct field names that you are using to store the phone numbers. For instance, if you are storing the phone number in a custom field named “Personal Phone”, the Marketo token you’re using might be named {{lead.Personal Phone}} and you will need to update the code to something like this instead.
mobilenumber = {{lead.Personal Phone}};
function removeNonNumericalChars(str) {
// Check for a leading plus sign and store the condition
const hasLeadingPlus = str.startsWith('+');
// Remove all non-numeric characters
let cleanedStr = str.replace(/[^0-9]/g, '');
// Prepend the plus sign if the original string had it
if (hasLeadingPlus) {
cleanedStr = '+' + cleanedStr;
}
return cleanedStr;}
var cleanedMobileNumber = removeNonNumericalChars(mobilenumber);
Now to test your webhook
3. Test your webhook by following a similar testing procedure as in our Part 1 blogpost
a. Create or edit the phone numbers of your test leads with some irregular phone number formatting
b. Create a Batch Smart Campaign and a Trigger Smart CampaignBatch Campaign will request the Trigger Smart Campaign
Batch Campaign will request the Trigger Smart Campaign
The Trigger Smart Campaign will call the webhook
c. Check to see that the smart campaign has run correctly
Conclusion
And that’s all there is to it! Wasn’t that easy? Now you can use this phone-number cleaning webhook however you like!
- You could call the webhook every time a new Person is created in Marketo with a non-empty Phone Number field.
- Or perhaps you can get it to run everytime someone fills up a form.
- You could also schedule to run it periodically every 6 months or so by setting some campaign rules and using a batch campaign to call on the webhook every 6 months or so.
Do note that there are certain limits quotas the free community version of Flowboost is subjected to, as we have covered in Part 1.
Have fun experimenting and if you have any comments or questions leave them down below for us!