In a potentially significant ruling for the social media giant, the court banned a shopping website from using the function on its pages if it did not first warn customers their data was being recorded.
The Fashion ID site, run by the Peek & Cloppenburg brand, was warned that it could be fined €250,000 for every breach of the order, seen by AFP.
The retailer will now be forced to warn users that 'liking' the site on Facebook grants permission for the company to log their IP address.
They will also be forced to tell users that they can withdraw their consent at any time.
Fashion ID will now be able to appeal the order, made in a civil court in Dusseldorf after a case was brought by the Verbraucherzentrale consumer organisation.
The body accused the site of failing to abide by Germany's strict data protection laws, a particularly sensitive subject in the country.
In a statement they warned that users' browsing data was transferred to Facebook on pages with like buttons, even if they were not signed up to the website.
Facebook's use of data is already under scrutiny in the country where web users are protected by strong privacy rules.
The German competition commission opened an investigation into Facebook earlier this month over suspicions that it is abusing its dominant market position to impose illegal terms and conditions on its users.
“For web services like Facebook that are funded by advertising, users' data has enormous value. That is exactly why we must also examine any abuse of their dominant position (to see) if they have sufficiently explained the means and extent of data collection to their users,” Germany's Federal Cartel Office said in a statement.