This year's stock market rally may spur you to start thinking about getting rich -- after all, the goal of investing is to build wealth. The idea of this happening overnight or through buying just one stock sounds fantastic, but it's best not to count on this scenario as it doesn't happen often. Don't worry, though, because there's another even better path to wealth, and you have access to it.

I'm talking about long-term investing. And it's the best strategy because it could lead to lasting riches rather than a quick gain that may disappear as soon as the market changes direction. Long-term investing means buying a broad range of solid companies, gradually building up to 25 or more, and holding on for at least a decade. You can start this plan with any budget, even buying fractional shares of higher-priced stocks, and over time, you're likely to see your investment grow.

If some of these stocks take off right away, you might even feel a bit richer by 2024. Which ones should you start off with? Two e-commerce giants are no-brainers because they're market leaders, have solid earnings track records, and could continue to win over time. Let's check out these wealth-builders to buy now.

A hand holds out a handful of 100 dollar bills.

Image source: Getty Images.

1. Shopify

Shopify (SHOP 1.11%) is the secret sauce behind many e-commerce websites you shop on regularly. The company serves millions of merchants worldwide, offering them a turnkey solution for website creation, product sales and payments, marketing, managing their businesses and much more.

This has helped the company deliver a track record of rising earnings, only halted by the expense of building a logistics business -- but this story actually turned out well. Earlier this year, Shopify sold the logistics branch yet continues to use its services. So, it's a win-win situation for the e-commerce giant, and we're already seeing the results in earnings.

In the most recent quarter, Shopify reported double-digit growth in revenue and gross profit. The period marked its fourth straight quarter of positive free cash flow, with free cash flow margin reaching 16%. That's compared to a negative free cash flow margin of 11% in the year-earlier period. So, we can see Shopify is growing earnings and transforming more and more of its revenue into free cash flow.

The company also offered a bright outlook for the year, saying this trend in rising free cash flow margin will continue -- and Shopify forecast full-year revenue to increase at a "mid-twenties percentage rate."

Shopify is the leader in the U.S. e-commerce software market with a 28% share, according to Statista. Considering this, Shopify's earnings trends, and the fact that e-commerce is a high-growth market, there's reason to be optimistic about the company's future.

Even though Shopify stock has soared this year, its market capitalization remains well below past levels -- and revenue has climbed significantly. So, there's plenty of room for the top e-commerce stock to grow from here.

SHOP Market Cap Chart

SHOP Market Cap data by YCharts

2. Amazon

Amazon (AMZN 3.43%) also has traveled through a rough period in recent times, due to the difficult economic environment. This hit the e-commerce and cloud computing giant in two ways. Customers had less money to spend on general merchandise, and Amazon itself faced higher costs.

But the company took action, improving its cost structure -- through job cuts, efficiency efforts, and strategic investment -- and already is showing great results. After its first loss in nearly a decade last year, the company now is reporting a profit, double-digit gains in revenue, and huge increases in operating income and cash flow. For example, in the most recent quarter, Amazon quadrupled operating income to $11 billion, and free cash flow improved to an inflow of more than $21 billion from an outflow a year ago.

Importantly, the moves Amazon has made recently should help it stay on top in the two high-growth areas of e-commerce and cloud computing. In e-commerce, the company revamped its U.S. fulfillment system, transitioning to a regional model from a national one. This cuts down on transport distances, making deliveries faster and lower cost. That's great news for Amazon and its customers (and should keep them coming back).

As for cloud computing, Amazon Web Services (AWS) is making significant investments in artificial intelligence (AI) to serve customers who want to use the power of the technology -- without starting from scratch or managing their own infrastructure. So AWS, and Amazon overall, could become big AI winners down the road.

Today, Amazon is trading for 54 times forward earnings estimates, which isn't ridiculous for a growth stock -- and it compares to more than 80 a couple of years ago. Thanks to Amazon's recent efforts, the stock has plenty of room to run, making it a no-brainer to add to your basket of potentially wealth-creating stocks.