Did you ever wonder why the top tech firms have been so successful? I recently found out after my company toured seven Silicon Valley firms--Facebook, Twitter, LinkedIn, Netflix, Instagram, Square, and Airbnb--to find out what makes their cultures tick.

We got the full experience, exploring how their teams work on a daily basis in their transparent, high-tech spaces that serve as innovative idea cookers, and sharing meals in their cafeterias with seemingly limitless menu options.

Like everyone else who has ventured into the hallowed halls of these Silicon Valley giants, I was first struck by the awesomeness of these work environments. On the surface, this is reflected in the mind-blowing amenities, services, and "stuff" that you don't find at your average Fortune 500 company--or really any organization outside of the Valley.

On the Facebook campus, for example, we strolled by an onsite laundry service, bike repair station, and ice cream shop. We saw where employees can visit a staff doctor or dentist. And we noticed countless vending machines filled not with snacks, but hardware, which employees can access free of charge by scanning their badges. The other guided tours revealed similarly impressive in-house perks.

While you may be well aware that Silicon Valley is known for its cool culture and seemingly unbeatable fringe benefits, it may surprise you to understand why the tech firms have created these especially employee-friendly work environments. It all boils down to one word--productivity.

To follow their lead and provide an environment that nurtures creativity and fuels innovation to supercharge your business, consider these four steps:

Know who you want to attract and why. If an office space is the body of a company's soul, then clearly these tech firms have invested deeply in their commitment to creating a setting that's perfectly suited to embodying their ideal cultural vision. Part of that vision involves attracting a creative and innovative workforce--in particular, Millennials.

Silicon Valley has been smart about their mission to harness the talent of these younger workers. They've recognized that since people are getting married and having families later in life than previous generations, Millennials are more likely to be unencumbered and able to devote more of their lives to a company--as long as it's one they believe in.

Cater to the talent you want to attract. To lure talented, tech-savvy Millennials, the technology industry has done something that other industries haven't grasped yet--they've learned how to speak to the hearts and minds of this younger generation. They've put their vast resources behind tailoring a work environment to meet their unique needs, preferences, and drives, rather than just putting lip service behind those concepts.

Whether it's eating three gourmet meals a day at Facebook, taking in-office Pilates classes at Twitter, or enjoying a $2000-per-year travel stipend at Airbnb, these companies know what appeals to their target workforce--and they provide it in spades.

Yet these companies understand another thing about Millennials as well. They realize that this generation values something much greater than just free food and foosball tables, and that they're not motivated primarily by money. These fresh minds seek the kinds of intangibles that Daniel H. Pink identified in his book Drive: a strong sense of purpose, the capacity for autonomy, and an environment in which they can obtain mastery through ongoing learning and growth opportunities. It's the ability to make good on those intrinsic motivators that's attracting Millennials in droves to these companies (and the free food doesn't hurt either).

Understand what leads to productivity. Employee engagement is an excellent side effect of the above strategies, but the most successful tech firms measure their decisions through a very specific lens that has much more to do with productivity than happiness. They base their cultural constructs on the answer to a single key question. That is: how do we provide an environment that inspires those who work for us (particularly our engineers) to constantly innovate using lean principles, translate their ideas into reality, and ship new products out the door as quickly as possible, which translates to value for our customers?

With that goal as the starting point, each corporate perk is implemented not specifically to create worker satisfaction, but to make the business more productive. For example, providing goodies like meals, staff doctors, and free laundry service leads to more shoulders to the wheel because employees no longer have to deal with those matters outside of work, giving them additional time to focus on doing things they want to do--both at the office and outside of it. If work becomes a place people love to be, then the line between work and play becomes blurred, and no one blinks at putting in the 60-70 hour workweeks for which the Valley is famous.

Recognize what doesn't get the results you want. Not everything that might make employees happy results in increased productivity. Though pets are fuzzy and cute, Facebook decided that allowing them in the office just wasn't going to help people get more done at work--and left that perk out of their culture. But hardware-filled vending machines to avoid trips home to retrieve forgotten equipment? Now that increases productivity--and you'll find one in every building on Facebook's campus.

Tech firms are obsessed with improving the productivity of their engineering teams who will build their future products. Millennials are motivated by working at a place they will be happy, not soul-crushed--where they can have fun, be inspired, keep growing, and even change the world. So far, it's only Silicon Valley that has figured out when the former grants the latter their wishes, everybody wins.