The Challenge
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.
The Solution
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.
The Strategy
- Generate all possible variations of known correct email domains within an edit distance of 1 and 2. For example,
gmail.com
could have variations likegmaail.com
,gmial.com
, etc. - 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.
Code Snippet
Here's the code snippet that shows how we accomplished this:
Conclusion
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.