Costco (COST 1.01%) has remained steady in a market where rival retailers including Macy's (M 0.44%) and Sears (SHLDQ) have struggled mightily.

While both of those chains have lost sales and closed stores, largely due to customers moving to the internet, the warehouse club continues to add locations. Costco is not a massive growth story, but it is reliable at a time when many retailers -- not just Sears and Macy's -- have struggled to find a way to keep customers coming in.

In Q1 2017, Costco saw its total sales grow by 3%, and its comparable-store sales inched up by 1%. The chain also delivered earnings per share (EPS) of $1.24, up 14%, or $0.15 a share, over last year's EPS of $1.09.

These are solid numbers that show that while the membership-based chain won't be hitting a grand slam or even a home run in 2017, it has a formula with which it can crank out singles. That may not be super exciting to investors, but it's a solid strategy that will leave Costco standing in a time when certainly Sears, and perhaps even Macy's may not survive.

Costo's stores are still a draw for customers. Image source: Author.

Costco stores remain event shopping

Because consumers can buy pretty much whatever they want without leaving their homes, it takes more to get many shoppers off the couch. Costco has managed to beat that trend by making shopping at its locations as much about entertainment as buying stuff.

The chain regularly mixes up its merchandise lineup in a way that leads to discovery. A customer may come in looking for cereal and leave with that, but also with an eight-foot Teddy bear, a pool raft, or a new sweater.

Costco also makes its no-frills locations a draw by offering extensive sampling. Doing that also causes more shoppers to walk around the store, exposing them to more merchandise and leading to more impulse buys.

Nobody (or a least very few people) takes their family to walk around Sears for no reason. Costco makes it easy to do just that, offering cheap food, samples, and the possibility of finding that next big bargain as drawing cards.

Discounts increase loyalty

People join warehouse clubs to save money. Costco offers low prices to all its members, but it also offers two ways for customers to save more. People can opt to pay an extra $55 a year for an Executive Membership, which offers 2% back on all qualifying in-store or online purchases made with the retailer, or they can get the chain's loyalty credit card. That Visa card offers 4% off on gas (at Costco and elsewhere), 3% on travel and restaurants, and 2% back on purchases at Costco and Costco.com (among other rewards).

The credit card program has been a driver for the company, but Executive Memberships are key to its growth, according to CFO Richard Galanti. During the chain's Q1 earnings call, which was transcribed by Seeking Alpha (registration required), he noted that Costco had added 348,000 new Executive Members in the quarter.

"As I have said before, Executive Members are a little over a third of our base and a little bit more than two-thirds of our sales where Executive Members are offered," Galanti said.

It's a formula that makes sense: Give people a reason to spend more and to visit stores by offering better discounts. The fact that customers pay up front for that privilege is a masterstroke for the company,

Costco has a unique formula

For years many analysts assumed that the low prices offered on the internet would eventually cut into Costco's sales. What they did not foresee is that value is only part of the chain's allure to shoppers. Yes, people want to save money, and they are even willing to pay extra to do so, but the experience matters as well.

It's fun to go to Costco in a way that online retailers cannot duplicate. That, coupled with tying members into deals in which buying more helps them recoup their up-front costs, creates a sort of perfect storm that makes customers loyal to the brick-and-mortar chain in a way that struggling rivals like Sears and Macy's also can't copy.

Costco may not prove internet-proof forever, but it has built a pretty big firewall protecting its user base. It's hard to see an online retailer, or even another physical one, overcome that any time soon.