All Categories Integrations How To Separate First And Last Name Fields With Code By Zapier

How To Separate First And Last Name Fields With Code By Zapier

Does your CRM, E-commerce, or other tool combine first and last names into a single field?

Contact data comes in many different forms and at times the contact data you are hoping to use in ChurchStamp may have a combined first and last name. ChurchStamp requires that they be separated.

Fortunately, Zapier provides a tool that with a little JavaScript code and an additional step in your Zapier workflow, makes it easy to separate first and last names from a combined data field.

First, Create A Triggered Drip Campaign In ChurchStamp In “Test Mode”

Before you start, be sure to set up a Triggered Drip campaign in ChurchStamp that uses the Zapier integration. By default, the campaign will be in “Test Mode” to enable you to send test contacts through without actually sending mail. Double-check to make sure your campaign is in Test Mode. Here’s an article that describes this in greater detail: Zapier Triggered Drip Test Mode

Following the steps below ChurchStamp will help you separate your combined first and last name. In this example, we will be using Zapier to pull in contacts from Google Sheets.

  • Sign into your Zapier account at https://zapier.com

  • Click Make a Zap in the top right navigation

  • Name your Zap in the top left of your screen

Google Sheets Setup

  • Choose your App. Select Google Sheets

  • Choose Trigger Event. Select New Spreadsheet Row

  • Choose your account

  • Choose your spreadsheet and worksheet and click continue

  • Test a contact row is being pulled in correctly. If yes, click test and continue.

Code By Zapier Setup

Next, we’ll set up the Code By Zapier tool to run our JavaScript snippet:

  • Click the + symbol below the Google Sheet app and search for “Code by Zapier”

  • Add “Code by Zapier” and under Choose Action Event select Run JavaScript and click continue

  • Under Input Data add “FullName” with no spaces, special characters, and exactly as spelled to the first box

  • Under Input Data select the column that contains your combined name field

  • Under Code (required) remove all text in the input and paste the following JavaScript then click continue

Add The Following JavaScript Into Code By Zapier

Options with JavaScript Code

  • If your combined name field has the first and last name in reverse order replace “false” with “true” where “let isNameReversed = false”

  • If your combined name field also contains company names replace “false” with “true” where “let hasCompany = false”. This will help pass ChurchStamp requirements where a field contains either a single name with no white space or a single company name such as “ChurchStamp”.

Separate combined name continued

  • Click continue and then click test & review. Confirm that the combined name has been separated into firstname and lastname. If the combined name is being separated correctly, click test & continue and begin mapping fields to ChurchStamp

Add The ChurchStamp Step To The Zap

  • Search for ChurchStamp and select.

  • Under Choose Action Event select “Send and Track a Postcard or Letter” and click continue

  • Choose your ChurchStamp account and click continue. Sign-in may be required.

  • Choose your triggered drip campaign

  • When mapping fields to ChurchStamp, under First Name select Run Javascript to firstname

  • When mapping fields to ChurchStamp under Last Name select Run Javascript to lastname

  • Your combined name field may also contain company names. If so, in the “Code by Zapier” JavaScript set hasCompany = false; to hasCompany = true; under company(optional) select Run JavaScript to company. review the Options with JavaScript Code above for more information

  • Map the remaining address and personalization fields and when complete click continue.

  • Review the test and confirm the data is being separated.

  • If all is working correctly. Click Done Editing.

  • Log into your ChurchStamp account, visit your campaign dashboard, and click preview in the top right corner. A modal window will pop up and shortly after will show the mail pieces created in test mode.

  • Once confirmed everything is working as expected. Turn your Zap on and toggle your ChurchStamp Triggered Drip Campaign to Live Mode.

Your Zap Will Run Whenever Triggered

That’s it! Your Zap will automatically separate first and last names into the appropriate fields in ChurchStamp each time it is triggered.

Was this article helpful?

Thanks for your feedback!