Google and YouTube have agreed to pay $170 million to the Federal Trade Commission and New York state in the largest-ever settlement in an enforcement matter brought under a federal law intended to prevent companies from collecting personal data from children without the consent of their parents.

The companies were accused of unlawfully tracking the behavior of users below 13 years old and serving them targeted advertisements based on that information, the New York Attorney General’s Office said.