Has Facebook figured it out?

Matt Krantz | USA TODAY

LOS ANGELES — Has Facebook cracked the holy grail of the new mobile technology? Investors sure think so.

Shares of the largest social media company soared more than 30% Thursday in their best performance since the company went public last May, and at more than $34 a share are now within range of its much-maligned IPO price of $38.

The reason: The company appears to have figured out how to make money on its booming traffic on mobile devices, something that has dogged tech companies since mobile became the key to the future a few years ago.

Facebook's mobile magic led to an embarrassing reappraisal on Wall Street, which had totally soured on the company's future.

"We were wrong," was the title of a report by Richard Greenfield at brokerage firm BTIG, who had rated the stock a sell with a $22-a-share price target.

Colin Sebastian at Robert W. Baird, another brokerage firm, expressed a similar view. "The very negative view on Facebook is evaporating," he says "You can't ignore a billion users."

Profit reported this week by Facebook not only blew away forecasts but was also largely driven by a moneymaking machine inside the company linked to mobile apps. Only about a year after redoubling efforts to make money from mobile, Facebook saw its number of mobile users explode 51% during the second quarter. But more important for a company that was created for desktop computers, now 41% of advertising dollars comes from mobile devices.

"They're lucky," says Rick Summer of Morningstar. "They have fantastic assets that translate well to a mobile experience."

Facebook's success in turning tiny ads on screens into a key part of its business highlights:

• The importance of where mobile ads appear. Nearly all of Facebook's mobile revenue is generated by ads inserted between entries on users' newsfeeds, Summer says. These ads are proving to be effective in getting users' attention without annoying them, he says, at least so far. Also catching on are ads in mobile Facebook apps that prompt users to download another app, according to Summer. "They have a format that works," he says.

• The need to keep prices up on mobile. One of investors' top concerns with mobile ads is they tend to be priced below desktop ads because they're so small. But Facebook is bucking the mobile discount because its users don't seem to mind the ads, Summer says. Much of Facebook's success with mobile, too, is a function of it getting more sophisticated at dealing with advertisers, Sebastian says. Facebook is giving advertisers better tools, for instance, to track the effectiveness of all ads, which helps attract and keep more ad dollars, he says.

• The fact that the shattered dreams of the pre-IPO era have been resurrected. Investors thinking Facebook had no limit lined up to buy at $38 a share a year ago. But the company's luster faded along with the stock as investors assumed the social media juggernaut would have trouble adjusting to mobile. Now that it is exhibiting such prowess, shares are soaring, jumping $8.20, or 30.9%, Thursday to $34.71.

Despite the impressive turnaround, challenges lie ahead. At $34 a share, the stock is fairly valued, Summer says, so the company needs more tricks to get back to $38 a share and beyond. A key goal will be boosting the mobile ad business tenfold or more, something that Facebook's current setup doesn't allow and will require more breakthroughs, he says. "There are," Summer says, "still lots of things to figure out."