Finding the best stocks to buy for long-term growth and returns isn't always easy, particularly in the current market. More than ever, it's important to look beyond share price fluctuations and evaluate the underlying business at hand to determine whether or not a company makes sense for your portfolio. 

If you're looking to invest in tech stocks for the long term, here are two wonderful companies that you can buy and hold in 2022 and well beyond. 

1. Pinterest 

At first glance, Pinterest (PINS -0.19%) looks like your run-of-the-mill social media stock facing the abundance of headwinds afflicting tech companies in the current market environment. But a closer look reveals why the advertising powerhouse has so much potential to grow from here, even if the near-term road ahead presents more than its fair share of bumps. 

Pinterest makes the bulk of its revenue from advertising. Businesses of all sizes, from small brands to household names, pay to advertise to its hundreds of millions of users. At its core, Pinterest is an image-sharing website, which makes its platform an ideal place for brands across virtually any industry to place ads, in photo or video form, to target and/or build upon existing customer bases. In the most recent earnings call, newly minted CEO Bill Ready noted: 

We've built our ad platform so advertisers can meet users at every stage of their purchasing journey as they move from ideation, where brand advertising is most effective; to consideration, where a traffic campaign makes sense; to taking action, where conversion objectives are optimal. Revenue from our ads align with these three objectives with approximately one-third of our revenue coming from each.  

In fact, Pinterest generated $2.1 billion in ad revenue in 2021 alone, while analysts expect this amount to nearly double to $4.1 billion by the year 2026. Now, many investors have gotten wrapped up in the fact that Pinterest's user growth has slowed in recent quarters after a surge during the earlier days of the pandemic. The company reported its first full year of GAAP profitability with a net income of $316 million in 2021. But it has dipped into unprofitability in recent quarters, choosing to invest aggressively in building out its platform and tools to attract and retain advertisers and users over the long term.  

However, looking at the bigger picture, Pinterest has actually grown its global user count at a compound annual growth rate (CAGR) of 11% over the trailing three years, while its revenue has increased by a 35% CAGR in that same period. Not only is the company's cash flow positive, but it closed the most recent quarter with a whopping $3 billion in cash and investments on its balance sheet while reporting adjusted earnings of $76 million.

While the near-term macro environment will pose challenges for any business tied to the global flow of ad spend, over the long term, Pinterest's innovative platform and strong foundation can enable it to thrive well beyond this period. 

2. Veeva Systems 

Veeva Systems (VEEV -0.57%) is a cloud computing stock that focuses on a very specific niche of customers. Its products and services are designed to meet the full spectrum of cloud software needs that arise among companies spanning the life sciences and healthcare industries. 

Over the years, the company has accumulated an impressive slate of clients that includes some of the most renowned names in the pharmaceutical and biotech spaces, such as Boston Scientific, GSK, Novo Nordisk, Merck, Moderna, and Edwards Lifesciences. However, Veeva's software is also used by other big names in adjacent industries with significant compliance obligations to bring their products to market, such as Colgate-Palmolive and Unilever

Veeva makes most of its money from subscription revenue. The company's subscription solutions target a wide range of needs. For example, one of its most popular offerings, the Veeva Vault Platform, enables users to do everything from connect with external suppliers and manufacturers to streamline industry-specific regulatory controls. 

Its broad suite of software solutions also helps clients launch and manage clinical trials, collate and manage clinical trial data, enact quality control systems, access real-time customer intelligence, review commercial and marketing analytics, and more. The other side of Veeva's business is its services, from which it makes a smaller but growing portion of its revenue. This includes offerings like technology business consulting and software certification programs. 

In the most recent quarter, Veeva reported $552 million in total revenue, a 16% increase from the year-ago period. $442 million of the top-line total was subscription revenue. The company has an established history of profitability, and its net income of $109 million in the quarter represented a 2% increase from the year-ago period.

Most of Veeva's clients are in industries that generally don't face much cyclicality, which offers far more resilience to their businesses -- and predictability for Veeva's business -- even in a challenging macro environment. This creates a compelling opportunity to buy this stock while it's trading at a discount compared to its tremendous long-term potential.