In our Shopify store, we faced the issue of having a large number of customer profiles with incorrect email domains. These were often due to minor typos or spelling errors, which could create issues like failed email deliveries and duplicate profiles. We had over 2,500 such customer profiles that needed cleaning.
Shopify provides a
Customer Merge GraphQL API that allows for merging two customer profiles into one. We utilized this API to merge profiles where the email domain had typos with those of correct email domains.
- Generate all possible variations of known correct email domains within an edit distance of 1 and 2. For example,
gmail.comcould have variations like
- Use these variations to identify customer profiles that are likely incorrect.
- Merge these profiles with the correct ones if they exist; otherwise, update the email to the correct domain.
Here's the code snippet that shows how we accomplished this:
Using Shopify's Customer Merge API and some Python scripting, we were able to clean up over 2,500 customer profiles with incorrect email domains. This not only improved the integrity of our customer data but also helped in enhancing the customer experience by ensuring that all future communications reach the correct recipient.