The study used 58,000 volunteers who alongside their Facebook "likes" and demographic information also provided psychometric testing results - designed to highlight personality traits.

The Facebook likes were fed into algorithms and matched with the information from the personality tests.

The algorithms proved 88% accurate for determining male sexuality, 95% accurate in distinguishing African-American from Caucasian-American and 85% for differentiating Republican from Democrat.

Christians and Muslims were correctly classified in 82% of cases and relationship status and substance abuse was predicted with an accuracy between 65% and 73%.

The links clicked rarely explicitly revealed these attributes. Fewer than 5% of gay users clicked obvious likes such as gay marriage, for instance.

Instead, the algorithms aggregated huge amounts of likes such as music and TV shows to create personal profiles.

It also threw up some strange pairings.

"Curly fries correlated with high intelligence and people who liked the Dark Knight tended to have fewer Facebook friends," said research author David Stillwell.

Data rethink

The study will be music to the ears of social media firms keen to make more money from customers via personalised marketing.

But the researchers warned that the digital profiles people are creating also threaten privacy.

"I appreciate automated book recommendations, or Facebook selecting the most relevant stories for my newsfeed. However, I can imagine situations in which the same data and technology is used to predict political views or sexual orientation, posing threats to freedom or even life," said Michael Kosinski, lead researcher on the project.

There are simple things users can do, said Mr Stillwell.

"Facebook likes are public by default but it is not that Facebook is forcing you to make them public; you have a choice to change your privacy settings."

He stressed that the results had implications beyond social media to all digital records - from browser histories to search queries.

"This research should ring alarm bells for anyone who thinks that privacy settings are the solution to protecting information online. We need to fundamentally re-think how much data we are voluntarily sharing," said Nick Pickles, director of privacy campaign group Big Brother Watch.

"Sharing individual likes or pages might not seem hugely intrusive, but it allows individuals to be categorised and behaviour predicted in areas that are far more personal and sensitive than people realise.

"Yet again, it is clear the lack of transparency about how users' data is being used will lead to entirely justified fears about our data being exploited for commercial gain."