This is a guest post from Charles Duhigg, the author of The Power of Habit: Why We Do What We Do and How to Change. Learn more at www.ThePowerOfHabit.com.

When you get to the cash register, what do you do first?

Do you imagine the balances due on various credit cards, and choose the one with the smallest outstanding debt? Do you mentally compare APRs and make the optimal financial choice? Do you calculate whether you actually need the product in your hands, versus its cost, versus the lost opportunity of using those dollars on something else?

Or do you just grab whichever card is on top of your wallet, and spend?

Most of the choices we make each day may feel like the products of well-considered decision making, but they’re not. They’re habits. And though each habit means little on its own, over time, how we spend our money — as well as the meals we order, how often we exercise, and the way we organize our work routines — have enormous impacts on our health, productivity, financial security, and happiness.

One paper published by a Duke University researcher in 2006 found that 45 percent of the actions people performed each day weren’t actual decisions, but habits. And it’s not just individuals. Procter & Gamble, Starbucks, Alcoa, and Target have seized on habits to influence how work gets done, how employees communicate, and— without customers realizing it — the ways people spend their money.

In the last decade, our understanding of the neurology of habit formation has transformed. We’ve learned how habits form within our brains — and why they are so hard to break. And as a result, we now know how to create good habits and change bad ones like never before.

At the core of this understanding is a basic framework that explains how your spending habits emerge — and how to change them.

RULE ONE: You must identify your habits
The tricky thing about habits is that they often feel almost unconscious. That’s because habits occur in a nearly unconscious part of our brain: the basal ganglia, one of the oldest neurological structures and the area where ‘unconscious thought’ occurs.

In the last decade, studies have taught us that there is a basic pattern at the core of every habit, a kind of neurological loop that has three parts: A cue, a routine and a reward.

To figure out how you spend, you have to identify your spending habits — the cues and routines and rewards — that drive how you handle money.

As an example, let’s say you have a bad habit, like I did when I started researching my book, The Power of Habit, of going to the cafeteria and buying a chocolate chip cookie every afternoon. Let’s say this habit has caused you to gain a few pounds. In fact, let’s say this habit has caused you to gain exactly 8 pounds.

How do you start diagnosing and then changing this behavior? By figuring out the habit loop. And the first step is to identify the routine. In this cookie scenario — as with most habits — the routine is the most obvious aspect: it’s the behavior you want to change.

My routine was that I got up from my desk every afternoon, walked to the cafeteria, and bought a chocolate chip cookie and ate it while chatting with friends. So that’s what I put into the loop:

When it comes to spending money, something similar often occurs when people walk into a store, or feel hungry and pass a fast-food restaurant, or receive their paycheck and automatically decide how much to save for the future and how much to spend next week. A routine takes over — and they act, almost unthinkingly, in ways that either fatten or deplete their bank accounts.

To take control over these habits, you have to identify them. And to do that, you need to look for patterns in your spending. Download your credit card data and ask yourself:

  • When do you spend? Is it more often on weekdays or weekends? Mornings or afternoons?
  • Do you make a few big purchases or a lot of small ones?
  • Do you spend more when you are with your friends or alone?

It won’t take long to find some basic patterns — and those patterns will highlight the routines that shape your financial life.

Next, some less obvious questions: What’s the cue for this routine? Is it boredom? Genuine needs like food and rent? Do you spend to socialize or entertain yourself on your own? Do you crave the things you buy, or the shopping experience itself?

To diagnose my cookie habit, I had to ask myself some similar questions. Was I eating because I wanted the cookie itself? A temporary distraction? Or the burst of energy that comes from that blast of sugar?

To figure this out, you need to do a little experimentation.

RULE TWO: Look for rewards
Rewards are powerful because they satisfying cravings. But we’re often not conscious of the cravings that drive our behaviors.

To figure out which cravings are driving particular habits, it’s useful to experiment with different rewards. If you, like me, were trying to change a cookie habit, I would suggest that on the first day of your experiment, when you felt the urge to go to the cafeteria and buy a cookie, you should adjust your routine so it delivers a different reward. Go outside, for instance, and walk around the block, and then go back to your desk without eating anything. The next day, go to the cafeteria and buy a donut, or a candy bar, and eat it at your desk. The next day, go to the cafeteria, buy an apple, and eat it while chatting with your friends. Then, try a cup of coffee.

You get the idea. What you choose to do instead of buying a cookie isn’t important. The point is to test different hypotheses to determine which craving is driving your routine. Are you craving the cookie itself, or a break from work? If it’s the cookie, is it because you’re hungry? (In which case the apple should work just as well.) Or is it because you want the burst of energy the cookie provides? (And so the coffee should suffice.) Or, are you wandering up to the cafeteria as an excuse to socialize, and the cookie is just a convenient excuse? (If so, walking to someone’s desk and gossiping for a few minutes should satisfy the urge.)

Spending is the same way: when you would normally spend away, try something else. One day, when you would normally take a break by buying an expensive latte, have a diet coke instead. The next day, take a walk and don’t buy anything.

By experimenting with different rewards, you can isolate what you are actually craving, which is essential in redesigning the habit. In my case, when I went to a colleague’s desk to gossip for a few moments, I found the cookie urge disappeared. What I was really craving, I realized, wasn’t cookies, but socialization. That was my habit’s real reward:

RULE THREE: Isolate the cue
Experiments have shown that almost all habitual cues fit into one of five categories:

  • Location
  • Time
  • Emotional State
  • Other People
  • Immediately preceding action

So, if you’re trying to figure out the cue for the ‘going to the cafeteria and buying a chocolate chip cookie’ habit, you write down five things the moment the urge hits (these are my actual notes from when I was trying to diagnose my habit):

  • Where are you? (sitting at my desk)
  • What time is it? (3:36 pm)
  • What’s your emotional state? (bored)
  • Who else is around? (no one)
  • What action preceded the urge? (answered an email)

After just a few days, it was pretty clear which cue was triggering my cookie habit — I felt an urge to get a snack at a certain time of day. The habit, I had figured out, was triggered between 3:00 and 4:00.

Similarly, when you spend (or save), write down those five things. What is triggering an unnecessary flow of dollars out of your account?

RULE FOUR: Have a plan
Once you’ve figured out your habit loop — you’ve identified the reward driving your behavior, the cue triggering it, and the routine itself — you can begin to shift the behavior. You can change to a better routine by planning for the cue, and choosing a behavior that delivers the reward you are craving. What you need is a plan.

A habit is a formula our brain automatically follows:

When I see CUE, I will do ROUTINE in order to get a REWARD.

So, I wrote a plan of my own:

At 3:30, every day, I will walk to a friend’s desk and talk for 10 minutes.

It didn’t work immediately. But, eventually, it got be automatic. Now, at about 3:30 everyday, I absentmindedly stand up, look around for someone to talk to, spend 10 minutes gossiping, and then go back to my desk. It occurs almost without me thinking about it. It has become a habit.

Changing some habits can be more difficult. But this framework is a place to start. Sometimes change takes a long time. Sometimes it requires repeated experiments and failures. But once you understand how a habit operates — once you diagnose the cue, the routine and the reward — you gain power over it. And study after study shows that the same is true with spending and saving: Once you figure out the cues triggering unnecessary spending, and the rewards it is delivering, the behavior can be changed. Once you learn to create cues and rewards to encourage automatic saving, studies say, our savings accounts expand.

GRS is committed to helping our readers save and achieve your financial goals.Savings interest rates may be low, but that’s all the more reason to shop for the best rate.Find the highest savings interest rate from Ally Bank, Capital One 360, Everbank, and more.