A few years ago, Google's human resources department noticed a problem: A lot of women were leaving the company.
Like the majority of Silicon Valley software firms, Google is staffed mostly by men, and executives have long made it a priority to increase the number of female employees.
But the fact that women were leaving Google wasn't just a gender equity problem - it was affecting the bottom line.
Unlike in most sectors of the economy, the market for top-notch tech employees is stretched incredibly thin. Google fights for potential workers with Apple, Facebook, Amazon, Microsoft, and hordes of startups, so every employee's departure triggers a costly, time-consuming recruiting process.
Then there was the happiness problem.
Google monitors its employees' well-being to a degree that can seem absurd to those who work outside Mountain View.
The attrition rate among women suggested there might be something amiss in the company's happiness machine. And if there's any sign that joy among Googlers is on the wane, it's the Google HR department's mission to figure out why and how to fix it.
Google calls its HR department People Operations, though most people in the firm shorten it to POPS.
The group is headed by Laszlo Bock, a trim, soft-spoken 40-year-old who came to Google six years ago.
Bock says that when POPS looked into Google's woman problem, it found it was really a new mother problem: Women who had recently given birth were leaving at twice Google's average departure rate.
At the time, Google offered an industry-standard maternity leave plan.
After a woman gave birth, she got 12 weeks of paid time off. For all other new parents in its California offices, but not for its workers outside the state, the company offered seven paid weeks of leave.
So in 2007, Bock changed the plan.
New mothers would now get five months off at full pay and full benefits, and they were allowed to split up that time however they wished, including taking some of that time off just before their due date.
If she likes, a new mother can take a couple months off after birth, return part time for a while, and then take the balance of her time off when her baby is older.
Plus, Google began offering the seven weeks of new-parent leave to all its workers around the world.
Google's lavish maternity and paternity leave plans probably don't surprise you. The company's swank perks - free gourmet food, on-site laundry, Wi-Fi commuting shuttles - are legendary in the corporate world, and they've driven a culture of ever-increasing luxuries for tech workers.
This week, for the fourth consecutive year, Google was named the best company to work for by Fortune magazine; Microsoft was No. 75, while Apple, Amazon, and Facebook didn't even make the list.
At times Google's largesse can sound excessive - noble but wasteful from a bottom-line perspective.
In August, for example, Forbes disclosed one previously unannounced Google perk - when an employee dies, the company pays his spouse or domestic partner half of his salary for a decade.
Yet it would be a mistake to conclude that Google doles out such perks just to be nice. POPS rigorously monitors a slew of data about how employees respond to benefits, and it rarely throws money away.
The five-month maternity leave plan, for instance, was a winner for the company. After it went into place, Google's attrition rate for new mothers dropped down to the average rate for the rest of the firm.
"A 50 percent reduction - it was enormous!" Bock says.
What's more, happiness - as measured by Googlegeist, a lengthy annual survey of employees - rose as well.
Best of all for the company, the new leave policy was cost-effective. Bock says that if you factor in the savings in recruitment costs, granting mothers five months of leave doesn't cost Google any more money.
The change in maternity leave exemplifies how POPS has helped Google become the country's best employer.
Under Bock, Google's HR department functions more like a rigorous science lab than the pesky hall monitor most of us picture when we think of HR.
At the heart of POPS is a sophisticated employee-data tracking program, an effort to gain empirical certainty about every aspect of Google's workers' lives - not just the right level of pay and benefits but also such trivial-sounding details as the optimal size and shape of the cafeteria tables and the length of the lunch lines.
In the last couple years, Google has even hired social scientists to study the organisation.
The scientists - part of a group known as the PiLab, short for People & Innovation Lab - run dozens of experiments on employees in an effort to answer questions about the best way to manage a large firm.
How often should you remind people to contribute to their 401(k)s, and what tone should you use?
Do successful middle managers have certain skills in common - and can you teach those skills to unsuccessful managers?
Or, for that matter, do managers even matter - can you organise a company without them?
And say you want to give someone a raise - how should you do it in a way that maximizes his happiness?
Should you give him a cash bonus? Stock? A raise? More time off?
Some of Google's HR lessons won't apply to other companies.
The search company has been insanely profitable for much of its history, and many of its problems are atypical.
Google has the luxury of worrying about the best way to give people more money instead of, say, the ideal manner in which to lay them off.
Still, a few of POPS' findings - like how to train a better corps of managers and how to improve interviews - will apply to most other firms.
And among the tech giants - many of which are also quite profitable and face some of the same problems Google does - the search company is alone in trying to answer its HR questions scientifically.
"We make thousands of people decisions every day - who we should hire, how much we should pay them, who we should promote, who we should let go of," says Prasad Setty, who heads POPS' "people analytics" group.
"What we try to do is bring the same level of rigour to people decisions that we do to engineering decisions. Our mission is to have all people decisions be informed by data."
This effort to bring rigour to HR grew out of Google's larger culture. Most of its workers are engineers, the kind of people who demand data to get them to change their ways.
One of the earliest examples of this was POPS' effort to streamline Google's hiring process.
In its first few years, Google became infamous in the Valley for asking prospective candidates to endure lots and lots of interviews.
"The intuition was that staffing was everything for Google, so everyone at the firm should be able to interview a candidate," Bock says.
The people in HR were sceptical of this approach; not only was the interview process slowing down hiring, it was also harming Google's reputation among prospective candidates.
So Todd Carlisle, who is now Google's director of staffing, did a study to find the optimal number of times a candidate should be interviewed.
He analysed dozens of Google's hiring decisions, keeping track of the scores that each interviewer had given a candidate after an interview. After crunching the data, Carlisle found that the optimal interview rate - the number of interviews after which the candidate's average score would converge on his final score - was four.
"After four interviews," Carlisle says, "you get diminishing returns."
Presented with this data, Google's army of engineers was convinced. Interview times shrunk, and Google's hiring sped up.
Google's HR department has uncovered many such nuggets of optimal organisational behaviour.
Among the biggest finding is that middle managers matter, which overturned Google founders Larry Page and Sergey Brin's one-time presumption that you could run a company in which nobody was the boss of anyone else.
POPS determined this by looking at scores the firm's managers received from two-sided feedback surveys, taking into account both what a manager's underlings and a manager's manager thinks about his work.
When analysts compared the highest- and lowest-performing managers, they found a stark difference - the best managers had lower attrition rates (meaning fewer people left their teams), and their teams were much more productive across a range of criteria.
"We were able to show them that those pointy-headed Dilbert caricatures actually make a difference to their jobs," says Jennifer Kurkoski, a PiLab analyst.
More importantly, the analysts were able to use their findings to make bad managers better.
After scouring the feedback that successful managers got from their teams, the researchers boiled it all down to eight bullet points.
They sound obvious and overly vague - "A high-scoring manager is a good coach," "a good communicator," "doesn't micromanage" - but the bullet points worked: When POPS spread these truths through the organisation and targeted unsuccessful managers for coaching, they found that the company's managerial ranks improved.
As a result of the coaching, Google managers' collective feedback scores have improved every year since 2009.
Another major POPS finding concerned how to give an employee more money.
In 2010, buffeted by the recession and increasing competition from other companies (especially Facebook), then-CEO Eric Schmidt decided to give all Googlers a raise. It was the job of POPS to determine the best way to offer that increase.
The group ran a "conjoint survey" in which it asked employees to choose the best among many competing pay options. For instance, would you rather have $1000 more in salary or $2000 as a bonus?
"What we found was that they valued base pay above all," Setty says. "When we offered a bonus of X, they valued that at what it costs us. But if you give someone a dollar in base pay, they value it at more than a dollar because of the long-term certainty."
In the fall of 2010, Schmidt announced that all Google employees would get a 10 per cent salary increase.
Setty says Googlers were overjoyed - many people cite that announcement as their single happiest moment at the firm, and Googlegeist numbers that year went through the roof. Attrition to competing companies also declined.
ARE LEADERS BORN OR MADE?
Then there are the smaller findings: To nudge someone to contribute to his 401(k), POPS found that it's best if you send him many reminders and that it's better if your reminders call for "aggressive" savings goals.
If you implore an employee to contribute $8000 to his retirement rather than, say, $2000, he'll tend to save more - even if he can't afford $8000, he'll put in more than he would have if you'd suggested $2000.
As for the cafeterias, researchers found that the ideal lunch line should be about three or four minutes long - that's short enough that people don't waste time but long enough that they can meet new people.
The tables should be long, so workers who don't know each other are forced to chat. And, after running an experiment, Google found that stocking cafeterias with 8-inch plates alongside 12-inch plates encouraged people to eat smaller, healthier portions.
Bock's ultimate goal is to use Google's experience to answer some big questions about the workplace: Are leaders born or made? Are teams better than individuals at getting things done?
Can individuals sustain high performance over their lifetimes?
POPS isn't close to being able to answer those questions right now, but Bock argues that Google can eventually shed light on some of them.
"We have the luxury of being a data-driven company with people with the analytic chops who can do the math," he says. "We also have a large enough scale so that when we run experiments, they're statistically valid."
In time, Bock argues, Google's findings - which it often shares with other HR professionals - may improve all our jobs. "You spend more time working than doing anything else," he says.
"If you work eight or 10 hours a day, it's more time than you spend sleeping, more time than you spend with your spouse. When you add it up it gets really depressing. You like your job, but for all time it should be - and it could be - something more. So why isn't it?"
Do you check your smartphone in bed?Related story: Smartphone etiquette - should you take it to bed?