Social media giant Facebook is being sued for the alleged monitoring of its users’ private messages in order to gather more consumer data that it in turn shares with marketers.

A federal lawsuit filed Thursday in San Jose, California alleges that Facebook traces the contents of users’ private messages, including links to other websites, "to improve its marketing algorithms and increase its ability to profit from data about Facebook users,” The Los Angeles Times reported.

A link to another site is read as a “like” of that website. The information contributes to a comprehensive profile on the user’s activity that is collected by Facebook and that eventually becomes material for targeted advertising, the lawsuit claims.

Two plaintiffs are seeking a class action suit on behalf of all Facebook users who have sent or received a private message in the past two years that contained links.

The allegations are “without merit,” said Facebook spokeswoman Jackie Rooney.

"We will defend ourselves vigorously," she told the LA Times in an emailed statement.

Hackers News was first to surface Facebook’s supposed practice of scanning private messages and converting links to “likes” in 2012.

Two weeks ago, a new study showed that Facebook records everything users type on the social networking site, including notes they choose to delete instead of posting.

Adam Kramer, a data scientist employed by the social network, studied the profiles of 3.9 million people for the study, dubbed “Self-Censorship on Facebook.” Kramer viewed activity on each profile by monitoring its HTML form element, which is made up of HTML code that changes whenever a user types in their Facebook chat, status update, or other areas where they speak to others.

While Facebook claims it does not track the words that are written in each box, the company is able to determine when characters are typed, how many words are typed, and whether they are posted or deleted. Kramer, with help from student Sauvik Das, spent 17 days tracking “aborted status updates, posts on other people’s timelines, and comments on other posts.”

The social network site does offer opt-outs for certain advertising features, such as whether a user’s consumer brand likes are shared with others and, perhaps tellingly, the ability to opt out of any future decision to allow third-party sites to use a user’s name or picture in advertisements.

Facebook - which is again expected to pay no federal taxes this year - is not alone among major tech companies facing lawsuits that claim privacy violations. Google has been sued in federal court, accused of illegally accessing the contents of email sent through its Gmail service, a violation of US wiretapping law.

Also earlier this month, documents leaked by former NSA contractor Edward Snowden revealed that the National Security Agency has quietly subverted the tools used by online advertising companies in order to track surveillance targets and improve its monitoring ability.