The UK will impose new rules next year aimed at preventing Google and Facebook from abusing their market dominance.
The Competition and Markets Authority (CMA) said the two firms accounted for around 80% of the £14bn ($18.7bn) spent on advertising online in 2019.
The new regime will attempt to give consumers more control over their data.
It will also "help small businesses thrive, and ensure news outlets are not forced out by bigger rivals," according to the government.
"There is growing consensus in the UK and abroad that the concentration of power among a small number of tech companies is curtailing growth of the sector, reducing innovation and having negative impacts on the people and businesses that rely on them," said Digital Secretary Oliver Dowden, in a statement.
"It's time to address that and unleash a new age of tech growth."
The new code will set clear expectations for the most powerful firms over what represents acceptable behaviour when interacting with competitors and users.
Platforms that are funded by digital advertising could be required to be more transparent about the services they provide and how they are using consumers' data.
They will be expected to give consumers a choice over whether to receive personalised advertising, and prevented from placing restrictions on their customers that make it hard for them to use rival platforms.
The code will be enforced by a new dedicated unit within the CMA.
The Digital Markets Unit could be given powers to suspend, block and reverse decisions made by technology firms and to impose financial penalties for non-compliance.
Google and Facebook have previously said they are committed to working with the British government and regulator on digital advertising.
Changes to news
The new code could also affect the media industry, which has lost much of its advertising revenues to Facebook and Google.
The new code will attempt to govern commercial arrangements between publishers and platforms to help keep publishers in business.
It will try to stop online platforms from imposing unfair terms on news publishers that limit their ability to monetise their content.