Before Febreze was a cleaning staple sold at groceries across America, Procter & Gamble declared it a dud and nearly pulled it from shelves.

Even though the company spent millions on the product, poor marketing almost cost them their investment, according to the book "The Power of Habit" by Charles Duhigg.

Procter and Gamble originally advertised Febreze to those they figured needed it most: people who smoked or had multiple pets. They were perplexed when the product barely moved from the shelves.

But their answer was in a basic psychological principle: operant conditioning.

Operant conditioning is the idea that a person's behavior is modified by its consequence. People strive to do things that make them feel rewarded.

But people who smelled bad were so desensitized they often didn't realize it, the researchers found. Because they didn't realize they smelled bad, there was no incentive for them to use Febreze.

Meanwhile, people who cleaned regularly craved the reward of a fresh smell at the end. Even if the room didn't smell bad to begin with, they liked to spray Febreze for the added fresh scent.

Once marketers honed in on what would make people want to use Febreze, it became the household staple it is today.

Here's a graph taken from the book. It shows the cycle of what the author calls the "habit loop."