The purpose of shaking is not merely to mix the ingredients, but to get the ice churning back and forth, which aerates the cocktail, giving it a pleasant, frothy texture and thoroughly emulsifying the ingredients into a more unified flavor. Shaking also will force any combination of ingredients to mix, regardless of how contrasting their consistencies are, from maple syrup, to eggs, to cream.
The most important aspect of shaking is to shake with gusto. It should be more than just a gentle jiggle. You'll typically want to shake for 8-10 seconds or so, depending on the ice you're using. In general, a cocktail should be shaken when it contains any non-alcoholic ingredients; citrus juice is the most common. These drinks tend to be brighter and more refreshing and benefit most from the effects of shaking. More about when to shake or stir certain types of drinks, and why, can be found on the Shaking vs. Stirring page.
Two Piece vs. Three Piece Shakers
There are two basic types of shakers. The two-piece, which consists of two different sized vessels wedged into one another, and the three-piece, which has a built in strainer on top covered with a third removable cap piece. You can learn more about the different types shaker is the Shakers page. The shaker I'm using on this page is a two-piece, more on why across the page. But you can make delicious cocktails with either (though I have my preferences) and the fundamentals of the actual shake are always the same: hold the shaker horizontally, throw your inhibitions to the wind, and give it hell.
A Two-Piece Shaker is a bit More Complicated...
Using a three-piece shaker is fairly self explanatory, you just put the top on and shake. A two-piece shaker involves a few more steps. Before you shake, the two halves need to be sealed together, so they don't open up while shaking, then separated so you can strain out the cocktail. All this is done with a few firm strikes from the heel of your hand, as we'll see below.
...But it is Better for Bartenders (and makes better drinks).
You may be wondering why one would bother with the extra steps of a two-piece. There are a couple reasons. One, while a three-piece is less complicated on the surface, once you get accustomed to working with a two-piece, it is faster and easier to use. For this reason alone it is the universal choice of professional bartenders. Additionally, in my opinion, the two-piece also makes better drinks because there's more space for the ice to move back and forth - which is the whole point of shaking.
Step 1: Build and Seal
The first step to making any cocktail - shaken or otherwise - is combining all the ingredients, aka "building" the drink, and then adding the ice (in that order). With a two-piece shaker you then have to seal the two halves together. If you're using a three-piece shaker the top fits right on, so this step does not apply. You can move right on to shaking.
It's good to be in the habit of building the drink in the smaller of the two mixing vessels - small metal tin or pint glass. If you fill up the larger tin with liquid and ice, the smaller vessel may not be able to fit. Or worse, if you are overzealously trying to fit more drinks into the shaker than it has space for (which I will confess to doing on more than one occasion) the liquid may overflow. Building in the smaller vessel ensures the shaker can always be closed and sealed and it will never overflow.
Add ingredients and ice into the smaller vessel. Fill it all the way up with ice. This will get the drink as cold as possible.
Place the large tin over the top on at an angle. Affixing the large tin at an angle is key to breaking the seal later. On one side, the tins should be completely flush with each other, on the opposite side, there should be a gap between them about a centimeter wide.
Form the seal. Give the top shaker a firm pop with the heel of your hand. You don't have to hit it too hard. In fact, it's better that you don't, or they'll be next to impossible to separate later.
Make Sure it's Set. To double check, lift the tin from the top end. The sealed shaker should lift right up.
Step 2: Shake!
Whether you have a two-piece or three-piece shaker, shaking can feel a little awkward at first. Just take a leap of faith, you’ll find your rhythm quickly. Speaking of which, shaking with a rhythm helps! Mine tends to be a kind of syncopated maraca beat.
Hold shaker horizontally. Holding it vertically won’t get the ice moving. It's not a bad idea to keep a hand, or at least a finger or two on each end for added support, at least at first. If you're using a two-piece shaker, the mouth of the larger tin should be facing you, just in case the seal does come undone - let us perish the thought - you wear the shaker's contents and not your guests.
Go for it! Thrust the shaker back and forth with all you've got! Shaking harder will give the drink a frothier texture and a colder temperature. I generally hold the shaker over my shoulder up by my ear, and let my elbows be the primary joint that moves it, rather than my wrists or shoulders. But do whatever works for you. There are a lot of different ways to shake.
Shake for 8-10 Seconds (or so). The range of shaking time depends on the ice. If your ice cubes are smaller, shake a little less, if they’re bigger, a little more. You can learn more about ice on the Ice Page. Shaking for too long or not long enough could over or under-dilute the drink. If you're unsure, taste it; it's the best way to learn.
Shaking is identical with a three piece. Only you absolutely need to keep a hand over the cap on the end, so it doesn't fly off.
Step 3: Break the Seal
If you’re using a three-piece shaker, you just have to muscle that little cap piece off and pour (don't lose it!). But with a two-piece, you have to separate the two halves to gain access to your cocktail. Methods of doing this vary. You may be able to just pull them apart, which is fine. But often a vacuum will be formed while shaking, causing the halves to cling to one another, making them virtually inseparable by force, no matter how much brawn you possess.
In this scenario, you need to hit the shaker at the right pressure point, or what I call the "sweet spot" (I know that's not the first time I've used that term, my imagination has fallen short). It's a bit like the "57" on a glass Heinz Ketchup bottle. When you hit it right, you'll hear the satisfying "crack" of the pieces releasing.
Hold shaker upright from the bottom of the larger tin. This positioning is important. Breaking the seal relies on the shock from the heel of your hand to release the pressure holding the tins together. If the shaker is resting on a table, or your hand is over the seam, some of the shock will be absorbed and it'll be tougher to separate the tins. Glass on tin is even harder.
Find the sweet spot. Here's where sealing the pieces at an angle comes into play. First, place you finger on the middle-point between the "flush side" of the shaker where there's no gap, and the "gap side" where there's that one centimeter of space, between the two tins. Then, move your finger an inch and a half down. That is the sweet spot.
Break the seal. It's time. Give the sweet spot a firm pop with the heel of your free hand. It’s not about hitting it really hard, just in the right place. When you hit it right you’ll hear a cracking sound echo out. Sometimes you'll hear a gentle hissing sound. That means you've dislodged the seal but not fully broken it. Hit it again, you're close!
Don't get frustrated. You may not get it on the first try, don't worry! This takes a little practice to get a good feel for. The most important thing is to not get frustrated and hit it so hard you hurt your hand. Remember, it's not about strength, it's about location. Take a deep breath, focus your chi, and try again. You'll get there.
Step 4: Strain
This is covered in detail on the Straining page. But since just about every time you shake a cocktail - or stir one for that matter - you're also going to strain it, I figured we might as well cover it here too. The strainer best suited to be paired with a shaker is a hawthorne strainer, which has slinky-like metal coil. On a somewhat unrelated note, notice that even though the particular drink in this example is being served on the rocks, it's still being strained over fresh ice, which is always a good idea.
Position. Place the Hawthorne strainer over the shaker, spring side down.
Hold. Secure it with your index finger.
Grip. Wrap your hand under the strainer handle and around the shaker.
Strain! Press down with your index finger. Lift, tip and pour.