When it comes to evaluating companies for their suitability as investments, no single factor should be more important for long-term investors than their sustainable competitive advantages -- otherwise known as moats. A wide moat is the compounding force that helps some companies (and their stocks) keep growing for decades, while the competition continually comes up short.

Each of the two companies I'll discuss below -- Shopify (SHOP -1.05%) and Atlassian (TEAM -0.83%) -- has a powerful moat already, but is rapidly adding another. This is setting them up for long-term dominance in their respective spaces that could last for a very long time.

Illustration of a castle with a moat.

The wider the moat, the better the investment. Image source: Getty Images

What, exactly, is a moat?

Generally, moats come in four forms:

  • Low-cost production: This allows a company to offer their product for a lower price than comparable alternatives. As an example, consider how Alphabet's Google is able to get data at very little cost thanks to its eight products with over 1 billion active users.
  • Network effects: This applies to situations where each additional user of a product makes it more valuable for other users. No company is a better example than Facebook. What's the value in a social network, after all, if none of your friends are on it?
  • High switching-costs: This relates to the "stickiness" of a product. The more pain there is involved in leaving a certain provider, the less willing customers are to put themselves through it. Most mobile phone companies used to accomplish this by locking customers into two-year contracts with high cancellation fees.
  • Intangible assets: This category normally includes such things as brand value (think: Apple), patents (think: drug companies), and government protection of a business (think: power companies).

The basics of software as a service

Now that we've gotten that out of the way, let's tackle the industry at hand: software as a service (SaaS). Few business models have taken off so quickly -- and profitably -- as SaaS.

If you're new to the idea, it's actually quite simple: In the past, if you (or your business) needed a computer program, you had to buy a CD or several for hundreds of dollars that contained the software, and install it on your computer. After that, you could use it for as long as your machine and operating system stayed functional and compatible with the program. But you might instead buy a new, better version every few years as advances induced you to upgrade. If a more compelling competing product hit the market, you might even switch. But you'd only benefit from the developer's ongoing process of upgrading their software when you made a new purchase.

SaaS flips this model on its head: Instead of a one-time purchase that gives you indefinite use of the software, you pay a monthly subscription fee for access to software that is hosted and accessible via the cloud. Those monthly fees are often nominal -- making it more enticing for you to subscribe. But over time, the software provider actually collects more revenue. You just don't feel it as keenly since it happens via small payments made automatically. But the users also benefit: Updates to the software are made frequently and incrementally, the customer is always using the most up-to-date version, and they avoid expensive up-front costs. 

Over time, individuals and -- in the case of this article -- companies that start using SaaS products will find themselves constrained by high switching costs. Consider Shopify, which provides a platform that allows just about anybody to gain an e-commerce presence. Once owners and employees get used to Shopify's interface, and have stored all of their data with the company, they tend to be loathe to switch. They'd rather spend their time focusing on their businesses.

The same is true with Atlassian: The company provides an enormous suite of products that help employees at IT and software companies communicate with one another, and track and build projects. Once employees become adept with these tools, most don't want to deal with the cost and headaches of switching.

No metric better gauges the size of this moat than the revenue retention rate. That measures the amount of revenue Shopify or Atlassian gets from a cohort of customers in Year Two, as compared to Year One. The advantage is that it filters out the effect of new customers, while telling us, first, if customers are sticking with these companies, and second, if they are adding more functionality over time.

In three of the past four years, Shopify's revenue retention has been over 100% (it didn't officially reveal numbers for 2018). Unfortunately for investors, Atlassian doesn't officially break the metric out. But its breathtaking pace of subscription revenue growth -- almost 300% in less than three years -- clearly shows the company is holding onto customers.

The presence of this moat alone would be enough to give investors confidence -- and both stocks justified that confidence, returning an average of 550% over the past three years.

Check out the latest earnings call transcripts for Shopify and Atlassian.

But network effects are gaining hold!

But here's the exciting thing: Both Shopify and Atlassian are starting to benefit more from network effects as well. However, those network effects operate a bit differently than they do for a company like Facebook.

Here's how it works:

  • Shopify and Atlassian allow third-party app developers to build tools for their platforms. For instance, there's an app on Shopify to help you source suppliers. Shopify didn't create it -- someone else did.
  • As more and more customers sign up for their SaaS offerings,  more third-party app developers are incentivized to build on those platforms.
  • As more tools become available on these platforms -- many times, only on these platforms -- they attract more customers to join Shopify or Atlassian.
  • This creates a virtuous cycle.

The best estimates are that Shopify now has around 2,200 apps available in its app store. It only keeps a 20% cut of sales of those apps -- not a huge needle-mover. But that's not the point: They make the platform more valuable -- and Shopify doesn't have to do much of anything.

As one app builder for Shopify put it in a Digiday article:

"To build a Shopify-like e-commerce platform is not hard to do. What's very hard to do is replicate the partnership ecosystem and the value they drive. It's their moat...It's not the software — their competitive advantage is the partnerships."

Similarly, Atlassian opened the Atlassian Marketplace in 2012 for third-parties developers to offer their wares. There are over 4,000 such apps available, and the company takes a 25% cut of the sales. 

Most impressive, momentum seems to be building: It took five years for total app sales to cross $250 million. But in only six more quarters, they doubled to $500 million. And in 2018 alone, Atlassian Marketplace recorded $200 million in sales.

Take a closer look

This doesn't necessarily mean you should go out and fill your portfolio with only these two companies. Every company has its risks -- and expensive stock prices are one of them. By almost every traditional metric, these shares are pricey. Buying a small position now and adding to it as you become more familiar with the company makes more sense.

I've devoted about 9% of my portfolio to these two companies. The combination of their high switching-costs and burgeoning network effects give me confidence that those investments will pay off handsomely in the long run.