When a company has its IPO -- or initial public offering -- it's the first time that ordinary investors have a chance to buy a tiny slice of the company. As I'll cover below, investing in IPOs isn't for everyone. Shares of newly IPO'd companies can often soar or sink to dizzying levels during their first few months on the market.

Take Beyond Meat, for example. The company -- which offers plant-based meat alternatives that are becoming increasingly popular at fast-food chains -- went public on May 2. Shares started trading at $25 apiece. Less than two months later, they were topping out at $200. That's insane -- a $15,000 investment was worth $120,000 in a matter of weeks. We'll have to wait to see where the stock goes in the long term.

Of course, the early days aren't always so rosy. Back when Facebook went public in 2012, shares lost more than 50% of their value in less than four months. That might've scared investors out of the stock, which would have been a huge mistake: Shares returned more than 1,000% in the ensuing six years.

The words "initial public offering" written on a chalkboard.

Image source: Getty Images.

As you can see, stocks can be volatile right after they first start trading publicly. That can make holding shares in a newly IPO'd stock trying on the nerves. In fact, we've talked extensively here at The Motley Fool about the perils of investing on the first actual day of trading: Things can get so volatile that it's best to wait a few days or weeks to dive in.

And I'm not a huge fan of "big" buys on recently IPO'd stocks either. These are companies that have limited operating history. Most people are just starting to kick the tires. If you don't have a solid thesis for investing in the stock, a set of metrics to test your thesis, and the conviction to hold regardless of what the stock is doing, it isn't for you.

But that doesn't mean you need to avoid recently IPO'd stocks altogether. This is where I can help out. Below, I'll discuss five stocks that have had their IPO since Jan. 1, 2017. For each one, I'll describe what the company does, why I believe in it, and how you can check to see if the company is delivering.

Just as important, I have my own skin in the game: I own shares of all five companies.

Company IPO Date What It Does
Okta (NASDAQ:OKTA) April 2017 Helps companies manage access to online documents.
Roku (NASDAQ:ROKU) September 2017 Provides a platform for all of your streaming services.
MongoDB (NASDAQ:MDB) September 2017 Enables database and search capabilities for companies.
Zuora (NYSE:ZUO) April 2018 Offers billing solutions for subscription-based companies.
PagerDuty (NYSE:PD) April 2019 Helps respond to technical outages on websites and servers.

Let's dive in!

Okta: Managing identity in the cloud

The cloud, or the global network of servers connected to the Internet, stores more vital data than we could ever imagine. And the sheer volume of such critical data -- including things like your Social Security number, test results from health screenings, and proprietary company information -- is only going to increase. Secured access to that data is paramount, and that's where Okta comes in.

This is a software-as-a-service (SaaS) company that helps companies manage which employees and customers have access to cloud-hosted data. As you can see below, the popularity of Okta's offerings is not in question -- especially among customers that are willing to shell out more than $100,000 per year.

Chart showing total Okta customers and those with annual contracts of over $100,000

Data source: SEC filings. Chart by author.

It's worth noting that the 2019 figures in that chart only take into account the first three months of its fiscal year, which started on Feb. 1. Since 2015, the total number of customers has increased 39% per year. More importantly -- and impressively -- the number of annual contracts over $100,000 has jumped 59% per year.

Okta benefits from two widening moats that set it apart from competitors. The first comes from high "switching costs." Once a company starts using a standard Okta tool, like single sign-on or multifactor authentication, it comes to rely on the service. Over time, customers start using more Okta tools to help keep their data secure and to give employees and customers access to data. In all, Okta has 12 different products -- though this number is sure to grow.

As customers add more Okta services and use them more, it becomes onerous to switch to an Okta competitor. Doing so might not only be financially costly but would also require retraining employees and reentering data permissions across the board.

The best way to measure Okta's success in becoming ever more deeply embedded in customers' DNA is to monitor the company's dollar-based retention rate (DBRR). This measures the total amount of revenue one cohort of customers spends from one year to the next. By filtering out the effect of new customers, we get an idea if customers are staying with Okta (DBRR near 100%) or even adding more services (DBRR above 100%).

Here are the results so far.

Metric 2014 2015 2016 2017 2018 2019*
DBRR 129% 120% 123% 121% 120% 121%

Data source: SEC filings. *DBRR for trailing 12 months as of end of the first quarter of fiscal 2019.

As if that weren't enough, Okta also benefits from "network effects": Each additional new user makes the service stronger for existing users. That's because the company uses "progressive" user profiling to make sure people on the Internet are who they say they are.

This type of profiling requires artificial intelligence and machine learning (AI/ML). Things like AI and ML become much more powerful -- and accurate -- when they have more data to learn from. Each additional customer adds to Okta's superiority in progressive user profiling, a fancy way of saying that the way Okta identifies users is always changing as it gathers more data. This makes it much harder for the competition to ever catch up.

I believe there's still lots of room to grow. The company is worth $15 billion to investors today, but thanks to the dual moats and huge tailwind of data migration to the cloud, I think we could look back in five years and consider today's shares to be a steal.

Roku: More than you know

Roku might be the only company on this list that the majority of Americans are familiar with. The company sells a $30 USB plug-in that allows you to access all of your streaming options from one interface on your TV. If you have a Netflix account, use Amazon for video rentals or Prime streaming, like watching PBS with the kids, and hop on YouTube when you're bored, you can do it all from Roku's interface.

On the surface, this doesn't seem like a very good money-making deal. But there's lots happening behind the scenes. Outside of those USB sticks -- or TVs that are sold with Roku's platform automatically installed -- the company has three other revenue streams:

  1. If a Roku user signs up for a new streaming service, Roku gets a small cut of that subscription.
  2. Any purchases or rentals of movies (like an Amazon rental) made on Roku's platform contribute a bit toward Roku's revenue.
  3. If someone watches ad-supported content using Roku, the company gets a cut of each ad impression.

The second item on that list is probably the least significant. The first item on the list might also seem weak, but we're about to see how that may change. Roku should hit 30 million customers by late 2019, and Disney is set to come out with its own streaming service later this year -- available on Roku. If any of those 30 million sign up for the Disney+ service, it will show up on Roku's income statement, though details aren't clear on how big that cut will be.

But by far the most important contributor is the ad-supported revenue. If you watch YouTube or any other such service on Roku, each additional hour spent viewing means cash for Roku.

Three key metrics will help investors monitor how well Roku is monetizing its growing user base: total accounts, hours streamed (remember, more hours usually means more ads), and average revenue per account.

Metric Q1 2017 Q1 2018 Q1 2019
Accounts (millions) 14.1 20.8 29.1
Hours streamed (billions) 3.3 5.1 8.9
Average revenue per account $10.04 $15.07 $19.06

Data source: SEC filings.

The key thing to note here is the leverage Roku gets from the transition to streaming. While customer accounts grew by 106% from the first quarter of 2017 to the first quarter of 2019, the number of hours streamed increased far more: 170%.

There's no way to know how many of those billions of streaming hours were spent on ad-supported channels. But even if they weren't, Roku is collecting data on viewing habits that it can then use to offer up more specifically targeted ads. That data is pure gold. Even if data is collected on users who don't watch ad-supported programs, it can be cross-referenced with those who share similar viewing habits and do watch ad-supported programs -- making the targeting more robust.

It might seem like Roku is in a precarious place in the value chain: It has relatively little content to speak of and simply serves as a place to access all of your content. But it is a powerful aggregator of viewers. Streaming services know that by putting their services on Roku, they get instant access to 30 million viewers. No one else can offer that.

Such an enormous head start leads to network effects: Streaming services put their content on Roku because of all the users, and users choose Roku because of all the services -- and the cheap, one-time $30 payment for the platform.

Roku is still worth just $12 billion. With the massive shift toward streaming continuing and a powerful position as an aggregator that benefits from network effects, I think Roku is an excellent investment at today's prices.

MongoDB: Organizing all types of data

If you haven't noticed by now, one of the themes of all these recent IPOs is data. It's everywhere, and it's extremely valuable. Being able to store, search, and analyze that data is paramount: Companies that can do that capitalize on opportunities the competition didn't even know existed.

For much of the past 20 years, such data was organized in something referred to as "structured query language (SQL) databases." In plain English, this means that data was stored in columns and rows.

But now, data is much more complicated. It is found in documents, collections, and many other different mediums. MongoDB is the market leader in organizing, analyzing, and allowing for search of these NoSQL (not only SQL) databases.

The company got its start by offering free downloads of its technology. Upgrades gave users access to more tools to help organize and use data.

Then in mid-2016, the company released MongoDB Atlas, a fully managed cloud database that is available on all of the major cloud providers: Amazon Web Services, Alphabet's Google Cloud Platform, and Microsoft's Azure.

In less than three years, Atlas already accounts for more than one-third of the company's revenue. Growth has been nothing short of astounding.

Chart showing Atlas revenue by quarter

Data source: SEC filings. Figures rounded to nearest whole number. Chart by author.

Incredibly, Atlas is still growing by more than 300% per year as of the end of the first quarter of fiscal 2020! Just as important, the number of annual six-figure contracts grew 52% year over year to 598 by the end of April.

Like other companies on this list, MongoDB is protected by multiple moats. When companies start using MongoDB to store their data, switching costs become very high. No one wants the headaches of data migration or the risk of losing mission-critical information. Additionally, MongoDB can continually tinker and add new products (like Atlas) that are easily sold to existing clients.

It also benefits to a lesser extent from network effects. The more customers MongoDB has, the more data it has on how such products are being used. The competition doesn't have this data, and it allows the company to continually innovate and offer new products.

I believe the forces at play -- and the continually growing importance of analyzing gobs of data -- will make this stock a long-term winner.

Zuora: Billing gets more complicated in the subscription economy

With Zuora, we have the first company on the list that has not impressed Wall Street with its results. Since going public last year, shares are down more than 20%.

Before we get into why that's the case, let's back up a little bit. Zuora founder and CEO Tien Tzuo was once an executive at the original SaaS company, salesforce.com. While there, he realized how powerful the subscription business model was becoming. It locks customers into long-term relationships with companies that are far deeper than a one-off purchase could ever accomplish.

But while that differentiated business model was appealing, it came with its own set of obstacles. One has to do with the difficulty in changing a company's accounting practices to recognize revenue in an acceptable manner over the course of the life of a contract. Believe it or not, that can create enormous headaches in accounting departments.

That's where Zuora's SaaS offering comes in. Customers use Zuora Billing or Zuora RevPro to handle these duties and get greater insight into where their business is headed. All of the software is compliant with Financial Accounting Standards Board rules, so it solves most of the headaches.

As you can see, customers with annual contracts of more than $100,000 have been voting with their feet when it comes to the software.

Chart showing Zuora customers with annual contracts over $100,000

Data source: SEC filings. Chart by author.

And don't worry about that recent plateau: The 2019 figure in this chart only represents one quarter's worth of data. As it stands, the number of these big spenders has grown from 242 at the end of 2015 to 546 at the end of March 2019.

But it hasn't all been smooth sailing. Revenue growth has slowed dramatically -- from 60% during the company's first quarter as a public company to 22% today. However, I've written extensively about why this is a little misleading: Subscription revenue is all long-term investors should really care about. "Service" revenue that comes with setting up customers is very low margin and is only important insomuch as it adds a valuable service that locks customers in. The total percentage of service revenue varies widely by quarter, depending on new customer onboarding during a given three-month period.

Chart showing total and subscription-based revenue growth at Zuora

Data source: SEC filings. Chart by author.

That said, even subscription revenue growth is showing signs of fairly steep drops. This is where we need to consider how difficult Zuora's task really is. MongoDB doesn't need to convince companies that data is important, and Okta doesn't need to convince companies that identity security is important.

Such is not the case at Zuora. Businesses are by their very nature conservative. Changing one's business model completely to focus on a subscription model is not an easy sell. While it may be the case that most businesses will adopt this format in the near future, it doesn't mean they're excited about it.

Zuora needs to do the evangelizing itself. And based on comments during the most recent conference call management held with analysts, it seems like newer members of the sales force are having a tough time winning over converts. Such hiccups are part and parcel of investing in companies that are changing the way we do business. At times, patience with how the process unfolds is necessary. I think this is one of those instances.

For long-term investors, I still think it's worth devoting a little capital -- say, 1% to 2% of your portfolio -- to the company. Shares have already been beaten down, and the company currently has a valuation of just $1.8 billion -- by far the smallest company on this list.

Zuora's dollar-based revenue retention rate of 110% shows that customers are sticking around, so I think it's worth owning a small number of shares today. If the transition toward the subscription economy gains traction, there are big rewards to be had for shareholders.

PagerDuty: Real-time response to major issues

Finally, we have one of the most ill-named companies on the markets today: PagerDuty. The company is the brainchild of founder and Chief Technology Officer Alex Solomon.

When Solomon was an engineer at Amazon, he realized that when bugs arose in Amazon's code, employees would be "paged" at all hours of the night to fix the problem. Oftentimes, only one or two people really needed to be alerted, but he would only realize that after hours of trying to fix the problem.

Armed with this knowledge, he started PagerDuty with the goal of accumulating all of the signals that servers send, figuring out a way to identify exactly where problems were, and notifying only the people who needed to be notified.

Since then, the company's offerings have grown: It now sells five different services. As you can see, they are proving popular with customers willing to fork over a minimum of $100,000 per year.

Chart showing PagerDuty customers with annual contracts over $100,000

Data source: SEC filings. Chart by author.

But here's the real big deal: We are still so early in PagerDuty's story. The company only went public a few months back. Existing customers are adding new "seats" (read: permissions for employees to use a service) and services rapidly.

That has led to a dollar-based net retention rate that is truly remarkable.

Chart of PagerDuty's dollar-based net retention over time

Data source: SEC filings. Chart by author.

Like the other SaaS companies here, high switching costs and the network effect provide critical moats. Unlike the other companies, however, the network effect is particularly strong here. It can be very difficult to sift through all of the signals that PagerDuty collects about the performance of a company's online services. And once a problem has been identified, it can take time to fine-tune whom to contact and how to fix problems.

PagerDuty's AI and ML are crucial in helping to streamline these services. And because the company is adding high-value customers hand over fist, it is also adding tons of data for AI and ML to feed on, thus improving performance as the system learns.

At its core, PagerDuty believes that it can one day offer a "weather report" for the internet. In other words, it can monitor all of the data it collects from all of its customers and use that to accurately predict where and when service interruptions might happen. But because it's the only one with access to the data, it's the only one that can offer such a service.

It's hard to know when PagerDuty would have enough data to be able to offer such a report. The biggest metric to watch would be the number of customers with $100,000+ contracts. Those would presumably be the ones providing the most data. Even if such a pie-in-the-sky goal comes more than a decade from now, it could be lucrative.

Imagine, if you will, that only one weather station in the world could offer accurate weather forecasts. It's not hard to imagine how profitable such a station would be. Thankfully for those of us who like to know tomorrow's weather without paying an arm and a leg, measuring our atmosphere doesn't work that way.

Measuring the internet, on the other hand, could. And by owning shares of PagerDuty, I believe we leave ourselves open to benefiting from that possibility.

A final word on investing in newly IPO'd companies

As I said at the outset, I own all five of these companies in my own portfolio. But never have I "backed up the truck" to buy a huge number of shares. IPOs are, by their very nature, volatile.

And SaaS stocks like those highlighted here are very richly valued. Here's what I mean by that: The average S&P 500 company trades at roughly 2.2 times sales. The five companies represented here trade, on average, for just over 20 times sales.

On one level, this makes sense: These are all small companies that are growing much faster than the more mature members of the S&P 500, so investors are willing to pay more for shares because they expect more growth. The SaaS business model also means that over time, more sales is kept as profit than in traditional business models. But we're also in uncharted waters when it comes to valuations so high for entire sectors.

Because of this, I have bought in small portions over time, adding shares when each company's progress has shown that my original thesis for investing was still holding true. Today, these five account for a relatively small part -- 13% -- of my family's invested money.

There will be time to add shares -- and benefit from price appreciation -- in the future if I'm right. If I'm wrong and shares drop, I'll be glad I left my exposure to these five at modest levels.

I suggest you consider taking the same approach to buying such recent IPOs.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.