Whether it is drug users being more inclined to show approval for Big Momma's movies or people with high IQ showing a taste for curly fries, the patterns are not always immediately obvious to the untrained eye.

Michal Kosinski, operation director at the University of Cambridge's Psychometrics Centre, said: "We believe that our results, while based on Facebook Likes, apply to a wider range of online behaviours.

"Similar predictions could be made from all manner of digital data, with this kind of secondary 'inference' made with remarkable accuracy - statistically predicting sensitive information people might not want revealed. Given the variety of digital traces people leave behind, it's becoming increasingly difficult for individuals to control."

The study, based on the Facebook profiles of 58,000 people in the US, found that online behaviour can be used to make surprising accurate predictions about users' race, age, IQ, sexuality, personality, substance use and political views.

After feeding Facebook preferences into an algorithm, they created models which were able to determine male sexuality with 88% accuracy, race with 95% accuracy, political leanings with 85% accuracy and religion 82% of the time. But few users clicked "likes" which explicitly revealed these traits. For example, fewer than 5% of gay users clicked obvious links such as "Gay Marriage" and instead inference were drawn from more popular likes such as TV shows.

The finding could be used to direct personalised marketing to web users but also highlights potential threats to privacy.

Mr Kosinski said: "I am a great fan and active user of new amazing technologies, including Facebook. 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. Just the possibility of this happening could deter people from using digital technologies and diminish trust between individuals and institutions."