Every company strives to obtain a following of loyal customers. Why? Because if it has customers who will choose its products over competitors', then it has one of the key ingredients for success: pricing power.

In the current economic climate, where consumers are armed with smartphones and the ability to price-check nearly everything, it can be tough to build up a cult following. Some companies -- like Apple (Nasdaq: AAPL), Amazon.com (Nasdaq: AMZN), and Costco (Nasdaq: COST) -- have had great success with this. Others, like Rite Aid (NYSE: RAD), have been left in the dust. What lessons should other companies learn from these success and failure stories? Let's take a look.

Do: Be innovative.
Among its many successes, creating a powerful brand is one thing Apple has mastered. The company took the time to carefully create a brand whose products not only represent high quality and innovation, but also defined the next generation of users: I'm a Mac, and I'm way more likable and accessible than stuffy old PC. You can (and should) be, too.

It's a message that's stuck in our minds and carried over into products like the iPhone and iPad. Over the last decade, investors in Apple have seen huge returns, up as much as 5,674%, and many analysts expect the stock's value to continue rising. Having a strong brand allows Apple to charge as much as they do. The company's operating margin is currently 35.7%, compared to Dell's 6.7%.

Do: Be trustworthy.
Costco's success comes from the opposite end of the spectrum. Members pay to gain access to huge warehouses where they know they'll find a reliable and steady stream of great deals in a clean and friendly environment. Anybody with $55 can be a member, and the company has one of the highest retention rates in retail (hovering around 90%).

Last October, when the company raised membership fees, analysts worried about the potential hit this could bring its bottom line. Members continued to stand by Costco, though, and the stock is up 10.6% since then.

Do: Be convenient.
In fact, don't just be convenient; redefine convenience. That's what Amazon is doing. Even if you hate what this company is doing to retailers, you have to admit that it's doing it well.

Amazon is dominating its industry and that's due in large part to its loyal member base. And while only recently did the company find a way to fully capitalize on its loyal customer base through annual Prime membership fees, the sheer volume of items it's sold since its inception is what has allowed the company to continuously sell things within such low profit margins. As more members join, the discounts can deepen, and loyalty could grow even more.

Don't: Be another brick in the wall.
Especially if that wall is about to crumble. Loyalty programs are all well and good, but every retailer has them and they aren't necessarily indicative of a truly loyal customer base.

Look at Rite Aid. A recent attempt to turn things around is its new free loyalty program, Wellness+. Unfortunately for the company, loyalty programs don't necessarily equal loyal customers. While membership numbers have been increasing, same-store sales have remained mostly flat.

Did you get all that?
Ulta Beauty
(Nasdaq: ULTA) is still trying to perfect its loyalty program, and seems to be doing well. Enhancing the program is part of its five-point strategy plan for growth. In 2011 alone, the program went from 1 million members to 9 million. Unlike Rite Aid, with more members came increased revenues, up nearly 20% at year end, and 2012 results have shown similar growth. The key to Ulta stoking more customer loyalty will be to implement the other broader concepts we talked about as well --  innovation, convenience, and trustworthiness -- otherwise its loyalty program will likely be ineffective.

Ulta is still young, but our analysts think it will be able to continue signing up new members and growing sales, and they have a pretty decent track record, currently beating the market by 80%. They've also found another great company with huge earning potential, and named it The Motley Fool's Top Stock for 2012. Click here to read everything you need to know in this special free report.