Image source: The Motley Fool.

Facebook (META 2.98%) stock is doing extraordinarily well lately: Shares of the social network are up by almost 40% year to date. Past performance is no guarantee of future results, but the following charts show that these impressive gains are sustained by solid operational and financial performance from the company; this bodes well for investors in Facebook stock.

An expanding user base

Users are the lifeblood of the business, as Facebook needs to have a vibrant and engaged user community in order to produce sustained growth in revenue and earnings. Fortunately for investors in the company, Facebook is doing quite well in this area. The company ended the second quarter of 2016 with 1.71 billion monthly active users, an increase of 15% versus the same period in the prior year.

Image source: Facebook.

As a reference, competitor Twitter (TWTR) has a considerably smaller user base of only 313 million monthly active users as of the end of the second quarter. In spite of its much smaller size, Twitter is significantly underperforming Facebook in terms of growth. The short-message social network increased its user base by 3% year over year last quarter. This huge gap in user growth is arguably one of the main reasons Twitter stock is down by 20% in 2016 while Facebook stock is booming.

Facebook has expanded lately into new platforms such as Instagram, Messenger, and WhatsApp, and the company is reaching massive scale in those segments. Instagram has over 500 million monthly active users and 300 million daily active accounts, while Messenger and WhatsApp each have over 1 billion registered accounts.

Importantly, engagement levels remain strong, which is a major positive in terms of evaluating the company's ability to sustain growth. According to CEO Mark Zuckerberg, time spent per person on Facebook, Instagram, and Messenger increased by double-digit percentages year over year during the second quarter.

Most of the growth opportunities in the social-media industry are currently coming from mobile devices, and Facebook is rapidly attracting new users in this area. The company has 1.57 billion monthly users on mobile devices, growing by 20% year over year during the second quarter.

Image source: Facebook.

Turning users into sales and earnings

Monetization is another key area in which Facebook is driving solid performance. The company is efficiently leveraging the massive amounts of information it has on its users in order to deliver more effective ads, and this is ultimately being reflected in increasing revenue per user.

Average revenue per user reached $3.82 in the second quarter of 2016, an increase of 38% versus the second quarter in 2015. Importantly, revenue per user in the U.S. and Canada is much higher, at $14.34. This means that Facebook still has considerable room to increase revenue per user on a global scale, if the company can bring monetization levels across the world to levels more in line with those of the U.S. and Canada.

Image source: Facebook.

A growing user base in combination with improving monetization is generating impressive revenue growth at Facebook. The company made $6.4 billion in revenue last quarter, jumping by 59% versus the same quarter in the prior year. Advertising revenue amounted to $6.2 billion during the period, an annual increase of 63%. 

Mobile is a major driver in terms of sales growth: Advertising revenue coming from mobile devices represented nearly 84% of all advertising revenue for the quarter, up from approximately 76% in the second quarter of 2015.

Image source: Facebook.

Facebook is investing for growth in areas such as people and technology, and this is generating considerable increases in expenses. Total expenses during the second quarter grew 33% year over year, to $3.7 billion. For the full year 2016, the company is expecting total expenses to increase in the range of 30% to 35% versus 2015 levels.

However, revenue is still outgrowing expenses, so profit margins are moving in the right direction. Operating profit margin grew from 31% of sales in the second quarter of 2015 to 43% of revenue. Income from operations more than doubled year over year, from $1.27 billion in the second quarter of 2015 to $2.75 billion in the second quarter of 2016.

Image source: Facebook. GAAP = generally accepted accounting principles.

In a nutshell, Facebook is producing solid user growth and engagement levels, efficiently monetizing user activity, and rewarding shareholders with rapidly growing sales and profits. With all these factors, it's easy to understand why Facebook stock is delivering market-beating returns.