Problem
You have a form on your website to collect email addresses, but users enter their email with a typo and you’re unable to deliver email to them. E.g. example@gmial.com
instead of example@gmail.com
.
Solution
I found this article in the customer.io docs titled “Fix typos in attributes”. However, it really should be titled “How to remove an attribute from a record” because it doesn’t fix a typo, it just removes an attribute.
Here’s how I fixed a common typo (that we were seeing) using JavaScript and some RegEx.
Step 1
Follow steps 1 and 2 in the above referenced article to create a segment that captures the misspelled attribute and to create a campaign using your new segment.
Step 2
- Use the Create or Update Person action in your workflow
- For the attributes to change, choose:
- ATTRIBUTE:
email
- VALUE:
JavaScript
- ATTRIBUTE:
- In the JavaScript field, I added:
return customer.email.replace(/@gmial\.com$/, '@gmail.com');
I appreciate how customer.io has the Preview attribute changes section that allows me/us to see if our JavaScript is going to have the desired change. Here’s a screenshot.