A judge has dismissed a lawsuit accusing Facebook of tracking users’ web browsing activity even after they logged out of the social networking site.

The plaintiffs alleged that Facebook used the “like” buttons found on other websites to track which sites they visited, meaning that the Menlo Park, California-headquartered company could build up detailed records of their browsing history. The plaintiffs argued that this violated federal and state privacy and wiretapping laws.

US district judge Edward Davila in San Jose, California, dismissed the case because he said that the plaintiffs failed to show that they had a reasonable expectation of privacy or suffered any realistic economic harm or loss.

Davila said that plaintiffs could have taken steps to keep their browsing histories private, for example by using the Digital Advertising Alliance’s opt-out tool or using “incognito mode”, and failed to show that Facebook illegally “intercepted” or eavesdropped on their communications.

“Facebook’s intrusion could have easily been blocked, but plaintiffs chose not to do so,” said Davila, who dismissed an earlier version of the five-year-old case in October 2015.

Clicking on the Facebook “like” button on a third party website – for example, theguardian.com – allows people to share pieces of content to Facebook without having to copy and paste the link into a status update on the social network.

When a user visits a page with an embedded “like” button, the web browser sends information to both Facebook and the server where the page is located.

“The fact that a user’s web browser automatically sends the same information to both parties does not establish that one party intercepted the user’s communication with the other,” said Davila.

The plaintiffs cannot bring privacy and wiretapping claims again, Davila said, but can pursue a breach of contract claim again.

Australian internet security blogger Nik Cubrilovic first discovered that Facebook was apparently tracking users’ web browsing after they logged off in 2011. Responding to Cubrilovic, Facebook engineer Gregg Stefancik confirmed that Facebook has cookies that persist after log-out as a safety measure (to prevent others from trying to access the account) but that the company does not use the cookies to track users or sell personal information to third parties.

However, in 2014 Facebook started using web browsing data for delivering targeted “interest-based” advertising – which explains why you see ads for products you have already been looking at online appear in your Facebook feed.

To address privacy concerns, Facebook introduced a way for users to opt out of this type of advertising targeting from within user settings.

“We are pleased with the court’s ruling,” said a Facebook spokeswoman.