Amazon (AMZN -1.61%) has been among the best-performing stocks you could own for a long time. If you'd invested $10,000 in Amazon two decades ago, it would now be worth over $571,000. However, that return used to be higher, as Amazon hasn't set a new all-time high since 2021.

But with how things are shaping up, Amazon could be set to notch a new all-time high in 2024. That could make it the biggest year in history for Amazon, and I think it's a wise idea to buy the stock now in preparation.

New business segments are boosting Amazon's gross margin

Amazon is far more than the e-commerce business that everyone knows. While Amazon used to be primarily a buyer and seller of goods, it's become more of a service-oriented business now, which is good for investors.

While its online stores still make up about 45% of total sales, it's growing at a slow 7% pace. One of its fastest-growing segments, third-party seller services, grew at a 20% pace and made up 27% of revenue. That's a critical transition, as Amazon is now selling its platform to other commerce companies to do business on while handling their payment transactions and delivery. This is a far more profitable avenue, as Amazon doesn't have to worry about finding the latest product or maintaining inventory, which falls on the seller's shoulders.

Amazon is also benefiting by selling more Amazon Prime subscriptions, up 14% in Q3, and it has a booming ad services division, up 26% in the same quarter. Although Amazon doesn't break out the profitability of each segment directly, we can use companies focused on subscription and advertising to deduce that these businesses are far more profitable than commerce.

The rise of these divisions is already having a huge effect on Amazon's gross profit margin.

AMZN Gross Profit Margin (Quarterly) Chart

AMZN Gross Profit Margin (Quarterly) data by YCharts

With these higher-margin businesses growing faster than their lower-margin ones, Amazon's gross profit has steadily risen to new all-time highs. This trend shows no signs of slowing in 2024, leading to new records.

The higher gross margin will also lead to improved profit.

Amazon's operating profit growth will provide record profitability levels in 2024

When founder Jeff Bezos was at the head of Amazon, he was always focused on the next biggest growth driver and on how big Amazon could get. Profit came second to growth, which hurt the company in 2022.

However, when Andy Jassy took over the CEO role, he began to focus on profit alongside growth, something that was crucial for Amazon's business maturity. While it took some time to work through Bezos' decisions, like excess warehouses and staff, the effects are now being felt.

In Q3, Amazon's operating profit margin approached levels set in 2021, when the stay-at-home boost from COVID was in full effect.

AMZN Operating Margin (Quarterly) Chart

AMZN Operating Margin (Quarterly) data by YCharts

With sustainable changes in place, Amazon will probably deliver at least 8% operating margin throughout 2024. That's something investors have never seen with Amazon and would make it a massive year for the company.

If Amazon grows its revenue by 11% to $572 billion in 2024, as Wall Street analysts project, and maintains an 8% operating profit margin, that would give Amazon a profit of $41.2 billion, assuming a 10% tax rate. That would value Amazon at 38 times 2024 earnings, which is still expensive.

But if Amazon can squeak out a few more points on its margin, up to 10%, that valuation falls to 30 times 2024 earnings.

This could be Amazon's biggest year, thanks to an improving margin. However, this trend won't be wrapped up in 2024; it's expected to continue for several years. If Amazon stays on this path, it will continue to be one of the best investments in the market.