The author is a Reuters Breakingviews columnist. The opinions expressed are her own.

Local brands are leading the race for China’s increasingly savvy consumers. From shampoo to snacks, upstart Chinese companies are eating into the market share of their foreign rivals, a new report shows. They heed digital trends, adapt to regional tastes and respond to customers’ increasingly sophisticated demands. Western firms that don’t follow suit risk being left behind.

Last year Chinese brands gained ground on foreign products for the fourth year in a row, according to data from Bain & Company and Kantar Worldpanel. In 26 types of fast-moving consumer goods ranging from groceries to toiletries, domestic darlings’ sales grew by 7.8 percent, while overseas brands saw sales slide 1.4 percent.

Shampoo brand Seeyoung shows the importance of not underestimating the sophistication of the consumer – a mistake that Procter and Gamble’s incoming CEO David Taylor admits has hurt China sales. Seeyoung has won admirers in the People’s Republic by introducing products free from the carcinogen silicone, leaving foreign peers to play catch-up.

Chinese companies also tend to be better at navigating the country’s unique internet universe. Foreign brands dominate the milk industry because of concerns about food safety. Yet local dairy group Yili has managed to grab market share through sponsoring local TV reality shows and clever online marketing. Snackmaker Three Squirrels, which launched online in 2011, reached sales of 2.5 billion yuan ($376 million) in 2015 using advertising that features cartoons which Chinese web users love to share.

Understanding regional differences is also increasingly important. The fastest rates of consumption growth are now in second-tier cities like Ningbo, Hangzhou and Tianjin. That’s harder for many multinationals which like to keep close tabs on what their Chinese managers are up to.

Foreign companies are learning these lessons: P&G’s Taylor has admitted that the company failed to give local executives enough latitude to respond to changing consumer trends. And the success in China of groups such as Starbucks and Nike suggests others have managed to avoid similar mistakes. As Chinese consumers become wealthier and more numerous, local knowledge will be the key to growth.