Facebook Inc. posted a better-than-projected gain in third-quarter revenue, indicating that a major advertiser boycott had a limited impact against the backdrop of a broader revival of spending on digital marketing.

The Menlo Park, California-based company said sales rose 22per cent to US$21.5 billion, compared with the US$19.8 billion average analyst estimate in a Bloomberg survey. While Facebook reached 2.74 billion monthly active users in the quarter, exceeding predictions, it saw an unusual decline in users in the U.S. and Canada, its most lucrative ad markets, as a pandemic-fueled surge from earlier this year leveled off.

In a movement spurred by civil rights leaders, hundreds of companies decided to halt advertising on Facebook in the month of July, asking the world’s largest social network to take greater responsibility for moderating hate speech and election misinformation that is often amplified on its sites. The robust sales gain underscores that, despite the criticism, Facebook is still the primary place for small and medium-sized business owners to reach customers.

Because COVID-19 shutdowns have driven an increase in online shopping, Facebook has been introducing more products for advertisers to sell directly to customers through its flagship site and its Instagram photo-sharing app. Revenue in the recent quarter likely benefited from that shift, as well as a boost in political advertising ahead of the U.S. election.

Investors were looking for a quarter helped by “better than previously expected advertising market recovery, accelerating political ad spend and incremental contributions from a flurry of product announcements related to social commerce,” said Rohit Kulkarni, an analyst at MKM partners, in a research note.

Shares were little changed in late trading, fluctuating between gains and losses. In the statement, Facebook warned of “a significant amount of uncertainty” in 2021, citing unpredictable online spending trends during the pandemic, regulatory challenges and changes to ad rules on Apple Inc.’s devices.

Facebook said ad targeting and measurement might become more difficult next year, not just because of regulations in Europe, but because of updates to privacy rules in Apple’s iOS 14 software. The social network will no longer collect unique device identifying information, known as IDFA, from iPhones, which Facebook and other companies have used to target ads to specific devices. In the new operating system, Apple users will have to agree to share the data with developers like Facebook.

The company said 2021 total expenses will be US$68 billion to US$73 billion, as it hires technical employees and invests in new product development. Facebook is also factoring in higher spending on budget lines that had been reduced this year because of COVID, like managing offices and business travel, if the pandemic comes under control.

Still, the third-quarter results offer evidence that the company’s business has so far been insulated from its mounting regulatory and political challenges. Chief Executive Officer Mark Zuckerberg testified in U.S. Congress again on Wednesday, facing questions about whether Facebook was fairly handling election-related content.

Alongside other technology giants, the company has also been the target of multiple investigations into its power and influence. A congressional committee released a report during the quarter concluding that Facebook has an unfair market advantage, and the Federal Trade Commission may soon announce whether it will pursue an antitrust case.

Amid the regulatory inquiries, Facebook has taken steps to further integrate its disparate social media and messaging products, making any potential breakup more difficult from a technical standpoint. Facebook recently combined the chat products on Instagram and Messenger, prompting users to merge their profiles. It also said users of its Oculus virtual reality headsets would be required to have Facebook accounts.

In a statement on Thursday, the company also said third-quarter net income rose 29per cent to US$7.85 billion, or US$2.71 per share, compared with the US$1.91 per share analysts projected.

Facebook shares closed at US$280.83 in New York before the report. The stock has gained 37per cent this year, far outpacing the 2.5per cent gain in the Standard & Poor’s 500 Index.