Meta founder and CEO Mark Zuckerberg speaks during the Meta Connect event at Meta headquarters in Menlo Park, California, on Sept. 27, 2023.

Josh Edelson | AFP | Getty Images

Last year at this time, Meta was navigating a crisis of confidence that had pushed its stock price to its lowest since 2016. Sales were dropping, TikTok was rising, and CEO Mark Zuckerberg’s bet-the-house wager on the metaverse was looking like a money pit.

Wall Street saw a very different story play out in 2023.

As of Friday’s close, Meta shares are up 178% for the year, on pace for their best year ever, topping the 105% jump in 2013, which was the year after Facebook’s IPO. The stock rose another 2.9% on Monday to $344.62, its highest in almost two years. It’s now just 10% below its record reached in September 2021, near the peak of the latest tech boom.

Among companies in the S&P 500, only chipmaker Nvidia had a better year, climbing 235% as of Friday.

Meta’s mega bounceback validates Zuckerberg’s declaration in early February that 2023 would be the company’s “year of efficiency” following the stock’s 64% plunge in 2022. Hefty cost cuts were at the top of his agenda, with Facebook’s parent company cutting more than 20,000 jobs and Zuckerberg acknowledging that economic challenges, stepped-up competition and advertising losses “caused our revenue to be much lower than I’d expected.”

After three straight quarters of declining sales last year, growth returned in 2023, and for the third quarter Meta recorded expansion of 23%, its sharpest increase in two years. The results were driven by a rebound in digital advertising and market share gains over rivals Alphabet and Snap.

The biggest catalyst, according to Longbow Asset Management CEO Jake Dollarhide, was Zuckerberg’s “change of attitude” and his willingness to listen to shareholder concerns instead of seemingly dismissing them in favor of his preferred mode of operation.

While Zuckerberg continues to invest heavily in the metaverse, which he sees as his company’s future, he’s refocused the business toward what actually matters today — advertising — and responded to investor concerns about out-of-control spending.

“It was the change in tone from Zuck,” Dollarhide said. “He went from thumbing his nose at shareholders” and talking about the billions he was spending on the metaverse “to listening and communicating in a different way,” Dollarhide added.

Plenty of challenges remain as the calendar turns to 2024.

Meta said in its latest earnings report that the digital ad market is still rocky, in part because advertisers are weighing the potential impact of the Israel-Hamas war. The company is also dealing with a number of new lawsuits that allege its products are harmful and addictive to children. And virtual reality continues to be a niche market, despite Meta’s hefty promotions of its new Quest 3 headsets.

“As long as the core business is humming along and is kind of improving, I think investors will probably continue to give them a pass,” said John Blackledge, an analyst at Cowen who recommends buying the stock.

Meta declined to provide a comment for this story.

Meta has now had well over two years to adapt to one of the most harmful changes to its business in the almost two decades since Zuckerberg started the company in his Harvard dorm room. In 2021, Apple updated its iPhone operating system in a way that gave users more control over how they could be targeted with ads. The update hit at the heart of Facebook’s ad business and resulted in the loss of billions of dollars of revenue.

As hard as Apple’s privacy changes hurt Facebook, they were equally devastating to other social media companies, most notably Snap. But Meta quickly got to work rebuilding its ad technology, with a major investment in artificial intelligence, and in the latest quarter reported much faster revenue growth than Google or Snap.

China has been a big part of the story. Susan Li, Meta’s finance chief, told analysts on the earnings call that online commerce and gaming “benefited from spend among advertisers in China reaching customers in other markets.” That means Chinese companies are spending heavily on Facebook and Instagram to send targeted advertising to the company’s billions of users around the world.

A Shein pop-up store inside a Forever 21 store in Times Square in New York on Nov. 10, 2023.

Yuki Iwamura | Bloomberg | Getty Images

JMP analysts estimate that e-commerce companies Temu and Shein, which both have roots in China, spent about $600 million and $200 million, respectively, on ads with Meta in the third quarter, leading to year-over-year growth of 44% from Asian advertisers.

In addition to Apple’s changes, Meta was also hurt in 2022 by the rapid rise of TikTok, which pioneered the short-video market, and a rotation out of tech stocks due to rising interest rates and surging inflation. All the while, Zuckerberg’s big bet on the metaverse continued to pile up billions of dollars in losses, underscoring the challenges of making virtual reality and augmented reality technologies appealing to mainstream consumers.

Altimeter Capital Chair and CEO Brad Gerstner wrote an open letter to Meta and Zuckerberg in October 2022 urging the company to “get fit and focused” by cutting staff and reducing metaverse investments.

Tom Champion, an analyst at Piper Sandler, told CNBC that Meta had to adjust to a rapidly changing reality. During Covid, digital media and e-commerce took off and, because the economy remained strong at the time, consumers and businesses had plenty of money to spend.

“We all extrapolated the growth trends around digital advertising that emerged during the pandemic, and Meta management invested behind that extrapolation of the trend as well,” said Champion, who has a buy rating on the stock. “The revenue picture changed a hell of a lot faster than cost.”

A few weeks after the Altimeter letter, Zuckerberg announced the first of what would be three rounds of layoffs affecting about 25% of the company’s workforce. Zuckerberg admitted to miscalculating what would happen when the economy reopened from the pandemic.

Reasons for skepticism

Meta’s initial round of layoffs in 2022 helped kickstart the stock’s rebound.

Then in February, Meta revealed that its total expenses for 2023 would be in the range of $89 billion to $95 billion, which was lower than its prior 2023 outlook of $94 billion to $100 billion.

The shares shot up 76% in the first quarter.

Ultimately, it appears as if expenses will be even lower than that revised number. Meta said in October that total costs for the year will be between $87 billion and $89 billion.

But, as Blackledge notes, Zuckerberg has so far largely spared the Reality Labs unit, which houses the company’s work in metaverse hardware and software. Meta said in its third-quarter report that operating losses in Reality Labs will “increase meaningfully year-over-year due to our ongoing product development efforts in augmented reality/virtual reality and our investments to further scale our ecosystem.”

The division lost $3.7 billion in the period and over $11 billion in the first nine months of the year.

Zuckerberg has spent much of the year touting Meta’s investments in AI, which has helped bolster its ad technology. Included in that conversation is the work Meta has done in building its large language model called Llama, which has gained popularity since OpenAI’s ChatGPT chatbot introduced the concept of generative AI to the mainstream.

“It’s a little tough for me to draw a line between a technology like Llama and the core business, but I think there are enough announcements and discussion and commentary from management to suggest that they are harnessing this technology in a lot of different ways,” Champion said.

Champion added that AI has helped Meta more efficiently operate its data centers, and he’s optimistic about the company’s use of AI to create more compelling digital assistants that could be useful for business messaging.

Despite Meta’s strong performance in 2023, Needham’s Laura Martin remains skeptical.

Martin has a sell rating on the stock, making her one of only two analysts tracked by FactSet without a buy or hold recommendation. She says 2024 will be a “cautionary tale” for the company because it still faces some major existential issues.

Meta doesn’t control a platform like Apple’s iOS or Google’s Android, which means it remains at risk of significant policy changes at those companies. While Meta eventually managed to weather Apple’s iOS privacy update through its AI investments, it now has to deal with Google’s upcoming plans to phase out third-party cookies in 2024, which will likely have a similarly weakening effect on its online ad business, Martin said.

“Cookie deprecation on Android is a big deal,” she said.

On top of that, Martin sees smart TVs as the area where advertisers are looking to divert spending as the major streaming platforms continue to pick up users who are abandoning linear television. That’s not Meta’s market.

Then there’s the influencer problem. Popular content creators are focusing their efforts on TikTok and YouTube, catering to younger audiences. A recent Pew Research Center study found that nearly 1 in 5 young adults say they use those video-streaming apps “almost constantly.”

TikTok, which is owned by China’s ByteDance, faces the risk of being shut down by U.S. lawmakers who have tried to make the case that it’s a national security concern. But that issue has been sidelined for months and in November a federal judge in Montana blocked a law that would have resulted in a statewide ban of TikTok starting in January.

Analysts aren’t expecting TikTok to go anywhere, meaning it will continue to pose a challenge to Meta.

“The regulators can’t get stuff done,” Martin said.

Piper Sandler’s Champion said he “personally can’t imagine in America where something like TikTok gets banned.” But he added, “Who knows — anything can happen.”

WATCH: Watch CNBC’s full interview with Liz Young, Sarat Sethi, Jim Lebenthal

Watch CNBC's full interview with Liz Young, Sarat Sethi, Jim Lebenthal, and Steve Weiss