Snap co-founder and CEO Evan Spiegel speaking at the 2018 Code Conference on May 29th, 2018.

Snap stock shot up as much as 21 percent in after-hours trading on Tuesday after beating analyst expectations across the board.

The company posted a narrower-than-expected loss for the fourth quarter as it managed to stabilize its base and prevent more users from fleeing Snapchat, the company's social app.

Here's how the company did compared with analyst projections:

Loss per share: 4 cents vs. 7 cents forecast by Refinitiv

4 cents vs. 7 cents forecast by Refinitiv Revenue: $390 million vs. $378 million forecast by Refinitiv

$390 million vs. $378 million forecast by Refinitiv Global daily active users (DAUs): 186 million vs. 184.26 million forecast by FactSet

186 million vs. 184.26 million forecast by FactSet ARPU: $2.09 vs. $2.05 forecast by FactSet

"We ended the year with user engagement stabilizing and have started rolling out the new version of our Android application to a small percentage of our community," CEO Evan Spiegel said on Tuesday in a statement.