To build a loyalty program for an e-commerce website, define the program goals and rewards, segment customers, set rules, and promote the program through various channels. Use a platform or software to manage the program and track customer engagement.