When you click a "like" button on Facebook, you could be telling the world whether you're gay or straight, liberal or conservative, intelligent or not so much — even if you don't intend to. That's what researchers found when they ran tens of thousands of Facebook profiles and questionnaires through a computer algorithm to find the obvious as well as not-so-obvious connections.

The results were published on Monday in the Proceedings of the National Academy of Sciences, and you can sample the method for yourself at a website called YouAreWhatYouLike.com.

"The main message of the paper is that whether they like it or not, people do communicate their individual traits in their online behavior," said lead author Michal Kosinski, operations director at the University of Cambridge's Psychometrics Center.

Some of the correlations are obvious: For example, If you're a fan of the "I'm Proud to Be a Christian" Facebook page, it's a pretty safe bet that you're a Christian. But others are hard to explain: Why is it that liking the "Curly Fries" page is associated with having a high IQ? Why does the computer model put "Sometimes I Just Lay in Bed and Think About Life" in the category for homosexual females, while "Thinking of Something and Laughing Alone" is linked to heterosexual females?

"These little patterns are really not perceptible to humans," Kosinski said. Sometimes, it takes a computer.

Kosinski and his colleagues conducted their experiment over the course of several years, through their MyPersonality website and Facebook app. More than 8 million people took the MyPersonality survey, which asked participants about their personal details and also had them answer questions about personality traits. About half of the test-takers gave their OK for the researchers to match up their survey results with Facebook likes, on an anonymous basis. More than 58,000 of the volunteered profiles from U.S. respondents were selected for matching.

The results were analyzed to produce correlations in more than a dozen categories, including five widely accepted personality attributes (openness, conscientiousness, extraversion, agreeableness and emotional stability). Those are the attributes analyzed on the "You Are What You Like" website. The other categories included IQ, religion, politics, sexual orientation, age, gender, race, relationship status, alcohol and drug use, tobacco use, life satisfaction, number of friends — and even whether a Facebook user's parents had separated by the time the user was 21.

This PDF file shows you which Facebook pages are the best fit for each of the categories.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Researchers set up a website that assesses your personality based on Facebook YouAreWhatYouLike.com

The researchers' computer model did the best at predicting black-vs.-white and male-vs.-female (95 and 93 percent accuracy, respectively). It could distinguish correctly between Republicans and Democrats 85 percent of the time, and between Christians and Muslims 82 percent of the time.

The accuracy rates for predicting sexual orientation were 88 percent for males and 75 percent for females. But don't think reaching that result was as easy as seeing who clicked the "like" button for "Gay Marriage." Less than 5 percent of the gay users were fans of such obvious pages, Kosinski and his colleagues said. The predictions were based instead on inferences from likes for less obvious pages. For example, the computer model associated the fan pages for Kathy Griffin and "Wicked, The Musical" with homosexual males, while heterosexual males were associated with the pages for Bruce Lee and WWE wrestling.

OK, maybe the pages weren't all that much less obvious.

The model wasn't as accurate (60 percent) when it came to predicting whether a user's parents stayed together or separated before the user turned 21. But even that level of predictive power could be "worthwhile for advertisers," the researchers said. "For instance, digital systems and devices (such as online stores or cars) could be designed to adjust their behavior to best fit each user's preferred profile," they wrote.

"I know the paper might sound like we're criticizing Facebook, but not at all," Kosinski told NBC News. "I'm a fan of Facebook."

Kosinski pointed out that an analysis of your credit card purchases, online music preferences, video rentals and Web browsing habits could come up with personal profiles at least as detailed as the ones that he and his colleagues produced. It just so happens that the Facebook likes were accessible enough to yield a vivid illustration of how such analyses work.

"It's possible this will lead some people to say, 'Maybe I shouldn't be using Facebook, or I shouldn't be using Google.' And that could be bad," he said. That kind of technophobia could hamper technological and economic progress, he said. Instead, the research should lead people to think twice about what they share online.

"We hope this information will help users start a discussion with organizations like Facebook, Google, Microsoft, or even policymakers about the rules of the game online," Kosinski said.

Update for 3:55 p.m. ET March 11: Kosinski's two co-authors, David Stillwell of Cambridge and Thore Graepel of Microsoft Research, passed along their comments in a news release from Cambridge.

"Consumers rightly expect strong privacy protection to be built into the products and services they use, and this research may well serve as a reminder for consumers to take a careful approach to sharing information online, utilizing privacy controls and never sharing content with unfamiliar parties," Graepel said.

"I have used Facebook since 2005, and I will continue to do so," Stillwell said. "But I might be more careful to use the privacy settings that Facebook provides."

More about Facebook research:

The PNAS paper, titled "Private Traits and Attributes Are Predictable From Digital Records of Human Behavior," includes a conflict-of-interest statement: Stillwell received revenue as owner of the MyPersonality Facebook app. Kosinski received funding from the Boeing Co. and Microsoft Research.

Alan Boyle is NBCNews.com's science editor. Connect with the Cosmic Log community by "liking" the log's Facebook page, following @b0yle on Twitter and adding the Cosmic Log page to your Google+ presence. To keep up with Cosmic Log as well as NBCNews.com's other stories about science and space, sign up for the Tech & Science newsletter, delivered to your email in-box every weekday. You can also check out "The Case for Pluto," my book about the controversial dwarf planet and the search for new worlds.