At NerdWallet, we strive to help you make financial decisions with confidence. To do this, many or all of the products featured here are from our partners. However, this doesn’t influence our evaluations. Our opinions are our own.

Travelers who collect miles and points know it’s often best to book directly with airlines and hotels. Third parties like online travel agencies don’t normally reward you with hotel points, so if you want to work toward free night awards at your favorite chain, it’s best to book directly.

But there’s one surprising place where it's smart to do a little comparison shopping before you book a hotel room: Airline websites.

Yes, the thought of booking a hotel at a website like United.com or AA.com is counterintuitive, especially for elite members of hotel loyalty programs who could miss out on special perks if they don’t book directly through the hotel. But with a little bit of luck, the airline could make it well worth your while by rewarding you with a hefty pile of airline bonus miles.

Booking hotels through American Airlines

Take, for example, a recent search for five nights in Honolulu: A room at the Royal Hawaiian, which cost $1,988 when we looked, was paying out an impressive 27,000 American Airlines AAdvantage miles when booked through AA.com. That’s more than 13 AAdvantage miles per $1 spent.

A 5-night stay at The Modern Honolulu, priced at $2,395 when we checked, came with a whopping 37,000 bonus miles — over 15 miles per dollar spent. That’s before you add on any bonus miles you'd earn using a rewards credit card.

Either way, you end up with more than enough AAdvantage miles for a round-trip domestic saver award ticket— just for booking a hotel on the airline website.

Not all hotel options are this generous; you’ll find plenty that earn just 1 AAdvantage mile per $1 spent. For example, the Alohilani Resort Waikiki Beach cost $1,405 when we searched for a sample 5-night stay. Booking that hotel earns just 1,405 AAdvantage miles.

Booking hotels through Delta

Searching for those same five nights in Honolulu on Delta’s website didn’t turn up any special bonus offers. Five nights at the Alohilani Resort Waikiki Beach booked through Delta.com cost $1,405 and earned 2,810 miles. The Royal Hawaiian cost $1,988 for five nights and earned 3,976 miles. In each case, that comes out to 2 cents per dollar spent.

Booking hotels through United

On United, the $1,988 Royal Hawaiian stay was earning 4,571 MileagePlus miles. The 5-night, $1,405 stay at Alohilani was paying 3,231 United miles. In both cases, the earning rate came to about 2.3 miles per $1 spent.

Is it worth it?

So should you just book your hotel room through an airline every time? Maybe not. When there’s no big bonus, the airline miles you earn for your hotel stay might not be worth the hotel points you'd forgo.

For example, when booking the Royal Hawaiian through an airline, you miss out on 10 Marriott Bonvoy points per $1 spent. If you have a Marriott credit card, you'd miss out on even more; for example, the 3 additional Bonvoy points per $1 you’d earn using the Marriott Bonvoy Bold™ Credit Card.

That $1,988 Royal Hawaiian stay could earn you nearly 26,000 Bonvoy points. Is it worth giving up those Bonvoy points to earn airline miles instead? That’s a personal calculation, but the answer is “probably not” if you’re trading them for just 4,571 MileagePlus miles or 3,976 Delta SkyMiles. But when a big bonus is in play, like those 27,000 AAdvantage miles, the equation gets turned on its head.

Another thing to consider: Reserving your hotel through an airline website could mean you’re missing out on deals and discounts offered at the hotel’s own booking site. On the other hand, the airline could offer a better cash price. That same Royal Hawaiian stay that cost $1,988 on the airline sites cost over $2,000 through Marriott when we checked.

Rates and bonus miles will vary by hotel and airline. The point is to check before you book. You could be rewarded with tens of thousands of airline miles.

How to Maximize Your Rewards

You want a travel credit card that prioritizes what’s important to you. Here are our picks for the best travel credit cards of 2019, including those best for: