If you want to gain members, one way to do it is to run a promotion where members can win your product for free for the rest of their life. Starbucks (SBUX 1.22%) is going to be offering My Starbucks Reward members the chance to win Starbucks for life, this winter. The reward program already has 8 million active members, and this is an opportunity for the company to jump that number up even further.

The popular program didn't happen overnight, though, and it's taken all sorts of innovative programs to grow the active membership to where it now stands. Even with its consistent growth -- membership was up 23% in the fourth quarter over the same period in 2013  -- Starbucks is developing new ways to make it easier for customers to give them money. Upcoming mobile ordering is just one such step. Here's how Starbucks is building its loyal following, and pre-empting the competition.

My Starbucks Rewards keeps the customers coming in
At the end of 2009, Starbucks relaunched its loyalty program as My Starbucks Rewards. The program now ties into mobile payments and registered gift cards, and allows users to build up status to get perks. It's like an airline reward program, but you don't have to go to Detroit to rack up points. As with all of these programs, the goal is to generate happy repeat customers by offering them small freebies.

Active membership stood at 5 million at the end of 2012. Since then, Starbucks has been working to add features, especially to its mobile payments system which integrates with the rewards program. That's helping build up a loyal base of customers to compete with the expansion of coffee retailers that's sweeping through the restaurant world.

Shops like Dunkin' Brands (DNKN) Dunkin Donuts and Panera Bread Company (PNRA) are fighting for the coffee drinking market. Dunkin' Donuts and Panera both posted mediocre comparable store sales increases this last quarter, growing 2% and 2.1%, respectively. Starbucks blew them out of the water with a 5% increase in comparable sales, demonstrating the staying power of loyal customers.

The competitive advantage of loyalty
Some of the advantages of loyalty programs are clear. Starbucks gets me to make 12 purchases and I get one free drink. The small cut into overall margin is more than made up for by the increased revenue. Beyond that, though, the company also learns a lot about its user base. How often customers make purchases, what kinds of drinks they like best, what times of day they order, and how they respond to direct marketing.

Those benefits offer Starbucks a competitive advantage over businesses that have smaller loyalty program user bases. Dunkin' Donuts and Panera both offer similar sorts of loyalty programs, but they're of different classes. Dunkin' Donuts' program has a mere 1.8 million members, meaning that it's barely scratching the surface when it comes to mining data or generating customer insights.

Panera, on the other hand, has 18 million total members, clearly giving Starbucks a fight for loyalty. The reason Panera isn't seeing the same kind of sales success even though it had a strong loyalty program comes down in part to the strength of the two brands, but beyond that to the running of the loyalty programs.

Starbucks has created a system that rewards purchases in a very direct way -- Gold members who buy 12 items get one free. Panera has no direct tie to rewards. In its explanation of the program, the company says that "part of the fun" is that rewards are "always a surprise." I can't speak for you but when I do something well -- a job, for instance -- what I like best is knowing I'm going to get a raise for working hard. Not a surprise.

Starbucks has the loyalty game figured out. Next year, it's adding mobile ordering and payment, which it promises will be launched as a "totally unique" offering, not just mimicking existing programs. The company is already talking about adding more features to the program over 2015 to keep customers hooked. That's going to be good news for rewards members and investors, as Starbucks looks like it's all in on customer satisfaction.