How to split full name in Zapier

How to split full name in Zapier and send it to Ontraport

Ever wanted to split the full name received from Facebook lead forms, Calendly etc into First and Last names and then send this data to your CRM or to another system? Here is a step by step guide explaining how to do that.

In this example, we will be using Calendly, Zapier and Ontraport.

Calendly will receive the full name. We'll use Zapier to split the names. And we will then send the data to Ontraport.

Let's get started.

Creating Zap and connecting Calendly

You probably already know how to create a new zap. Just click on the 'Create Zap' button

And then select Calendly as your first app. (If you're using Facebook lead form or any other apps, feel free to use them. But for this example, I will be using Calendly)

After choosing and connecting to my account, I will click on Test trigger to populate some previous data. If you don't have any previous data, I highly recommend to do a test booking.

[ Note : If you have a Facebook lead form and want to test your facebook lead form check this link. Please do note, you can test your facebook lead form only once. Lead Ads Testing Tool ]

When you pull the data from Calendly (or any app) you can see how it only shows the full name since in the form you only asked full name, not first and last name separately.

Now our task is to split this full name into Fist and Last Names. Let's see how it is done

Splitting full name using Zapier Formatter

This method works great if you get simple names with only 2 parts.

Click the plus sign to add next step and select 'Format by Zapier'

Once it is added, it will ask you what kind of event are you planning to format. Since names are text data type, we will select 'Text'.

It will then ask you what kind of transform are you looking for. We are looking to split the text. So find "Split Text" from the dropdown menu.

Now we have to select the Input. Our input - which is the full name - comes from Calendly in this example. Yours could be from fb lead form or similar. Select the full name in this field.

Now it asks you for a separator. The first and last names are usually separated by a space. So space will be our 'Separator'. It is represented as [:space:]

Just check the above image if you have any confusion.

Now we can segment this split texts and get one part of it, or all parts of it. When you click on the drop down you can see options like First, Second, Last, Second to Last, All as line items, All as separate fields.

If you only wants the first part of the name select First. If a person has a middle name it will be usually at the second spot. In that case if you want the middle name, select Second.

But here, we will be selecting All(as Separate fields) because we want all parts of the names, not just first or last.

So select "All(as Separate Fields)

This will store each part of the name as different items.

Once that is done, click Continue and test the action. Then you can see the output.

You can see that first and last names are stored as item1 and 2 and name splitting is a success!

When you select an app to send this info, you will see these options.

You can insert whichever output is available as per you requirement.

What happens when someone has a long name?

When someone has a long name such as Albert Newton Edison Alvarez and you want to save the name in just 2 fields, ie First and Last name.

The first name will have the first part, and last name with rest of the parts. Will Formatter by Zapier works in that case? The short answer is, yes it will work by adding a couple of more steps. But each steps, each zap runs will cost you money.

In such case, you can use Zapier code as mentioned below

Splitting full name into first and last names using Zapier Code

You can split a text using Zapier Formatter, but if you receive a longer name, it would split it into each items and would require multiple steps to make it into 2 parts- as first and last names.

But if you are using code, you can simply use one step to split the long names into two parts. And it is easy as copy pasting a few lines of text in certain boxes. I will guide you through the exact process. Don't get overwhelmed simply because you're using "code"!

We need to add the next step in order to get started. So we click the plus sign to add the next step.

In the search bar, type in 'Code' and select "Code by Zapier"

Once that is selected, it will ask you what kind of event you want to run. Since we are using a javascript code snippet, we will select "Run Javascript".

Zapier Javascript code to split full name

Below is the code we are going to use. You simply need to copy the whole code and paste in in the next screen when you click continue.


var splitName, fName, lName, output;


// get the first and last name from full name
splitName = inputData.full_name.split(' ');
fName = splitName[0];
if(splitName.length >= 2){
	splitName.shift();
	lName = splitName.join(' ');
} else {
	lName =	'';
}



// create the output for this step
output = {
	'first_name' : fName,
	'last_name' : lName,
}

Since we are using the variable "full_name" to store the full name, you have to use the same in Zapier too.

So the data we will be inputting will be first name, and the variable we store this will be `full_name`

You just need to paste full_name in input data box as shown in the image above. And select the complete name data from Calendly (or facebook lead form or any other app you will be using)

Inserting the code into Zapier

Now it is time to copy and paste the code into Zapier in the 'Code' box. First you need to clear whatever is there added by Zapier. simple select all and delete all the lines already in the box.

Once it is clear, simply add the whole code given above.

Once finished, it will look like this. Now it is time to test it. Click Test Action.

If everything is fine, you should see first and last name in two lines. If there are more than 1 part in the second name, it will appear as last name. If there is no last name, then an empty string will be assigned to last name.

Accessing first and last names

Now that we have first and last name saved onto 2 variables, let's see how we can access them and send it to other apps like Ontaport, mailchimp, google sheets and so on.

Click the plus button to add the next step and search for the app that you want to add next. I will be connecting my Ontraport account to send update my contact fields.

And when you click to any fields to add data fetched by Zapier, you will see options given from Code by Zapier.

Then you will find first name and last name among the options. So you have successfully split you full name! It wasn't that hard, was it?

Hope this helps.

PS: If you are a power Zapier user, you should definitely check out this cheaper Zapier alternative. And its got LTD!!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram