America loves its brands. The best brands are consistent, trustworthy, and high-quality. Many people believe that branding just means brainwashing consumers through clever advertising. However, as I will show with Starbucks (SBUX -0.63%), PepsiCo (PEP 0.57%), and Altria Group (MO 1.16%), it is more nuanced than that.

The best brands exploit what Charles Duhigg, author of The Power of Habit, calls the habit loop. There are three parts to the habit loop: cue, routine, and reward. The cue is a trigger that prompts you to carry out the routine, the routine is an activity that you automatically perform once you are given the cue, and the reward is that which you carried out the routine to attain. If the reward is good enough, the link between the cue and the reward will grow strong, causing you to habitually carry out the routine when given the cue.

Here is an example of how the habit loop creates habits:

It makes sense—when the kids are starving and you're driving home after a long day—to stop, just this once, at McDonald's or Burger King. The meals are inexpensive. It tastes so good. After all, one dose of processed meat, salty fries, and sugary soda poses a relatively small health risk, right? It's not like you do it all the time. But habits emerge without our permission. Studies indicate that families usually don't intend to eat fast food on a regular basis. What happens is that a once a month pattern slowly becomes once a week, and then twice a week—as the cues and rewards create a habit—until the kids are consuming an unhealthy amount of hamburgers and fries.

                                                                                                                                                                                                                        The Power of Habit pg 34

How Starbucks exploits the habit loop
Just like the family in Duhigg's fast-food example, Starbucks drinkers may not intend to become habitual coffee drinkers. The cue to get coffee may be morning grogginess on the way to work. Since Starbucks has locations just about everywhere, you stop by Starbucks to get a quick pick-me-up. After drinking Starbucks coffee, you are ready for the workday. Your brain likes changing from groggy to ready-for-day, and it learns that Starbucks can get you from one to the other, so you develop the habit of going to Starbucks whenever you are groggy in the morning.

Habits are difficult to break once they're formed. That's probably why Starbucks has unusually loyal customers; the 20% most loyal customers visit a location at least 16 times per month. That habit will only become more common -- as the link between cue and reward strengthens -- unless those customers make strong conscious efforts to break the loop.

Moreover, Starbucks' popular loyalty program only serves to reinforce this habit loop by amplifying the reward. Starbucks customers who use their loyalty cards will collect points toward free beverages and other rewards. This solidifies a customer's habit of going to Starbucks, rather than a different coffee shop, to reach the reward. As a result, Starbucks has built an everwidening moat in many consumers' minds.

PepsiCo wants you to reach for chips and soda
PepsiCo also exploits the habit loop to its benefit. The easiest habits to form involve those activities that people perform frequently which require little thought. That describes PepsiCo's products perfectly.

PepsiCo CEO Indra Nooyi argues that snacks and beverages go together. When you eat Fritos, you also drink a beverage. The two are a natural combination.

The cue could be that you are sitting down to watch television. The routine is to pop open a Pepsi, a bag of Fritos, and a can of bean dip. You do this automatically, without thinking, when you watch television. Your subconscious mind takes you through the routine because it gets you to the reward: an enjoyable snack or a quick energy boost.

To reinforce the habit, many of PepsiCo's products are formulated to keep you eating and drinking more than you should. For instance, many of its products contain copious amounts of sugar; a 20-oz bottle of Pepsi contains 69 grams of sugar. You feel energized after drinking a Pepsi because your blood glucose spikes, and then you crave another Pepsi when your blood glucose crashes as this leaves you feeling tired. This means that people who are in the habit of drinking Pepsi will continually increase the amount of Pepsi they want to drink -- not a bad business to be in.

Altria wants you to reach for a Marlboro
Of all the legal habits one can form, smoking is perhaps the hardest to break. Duhigg explains the habit loop phenomenon in the context of smoking as follows:

When a smoker sees a cue—say, a pack of Marlboros—her brain starts anticipating a hit of nicotine. Just the sight of cigarettes is enough for the brain to crave a nicotine rush. If it doesn't arrive, the craving grows until the smoker reaches, unthinkingly, for a Marlboro.

                                                                                                                                                                                                                        The Power of Habit pg 52

The smoker's cue could be that she is not stimulated, she is anxious or stressed, or she just gets a whiff of cigarette smoke. The cue immediately makes her think of the reward that follows her normal routine. So she goes through the routine of smoking a Marlboro -- a habit formed after many years of reaching for Marlboros. After smoking the cigarette, she is rewarded with more stimulation, less stress, or whatever drove her to smoke in the first place.

It does not hurt that nicotine is addictive, which undoubtedly reinforces the habit loop. However, the smoking habit loop is not all that different that the Starbucks habit loop or the Pepsi habit loop. This is the genius behind brands and the habit loop.

Foolish takeaway
Habits are hard to change; you have to actively strive to change them, and even then it is easy to fall back into old habits. That is why consumer brands are flourishing and what provides Starbucks, PepsiCo, and Altria Group with wide moats, which bar new brands from changing their customers' habits.