Macy’s is the largest brick-and-mortar U.S. department store chain, with sales of $28.1 billion last year.

But it knows full well that its future hinges on become similarly dominant in e-commerce. So like many other retailers, Macy’s M now has a sizable presence in Silicon Valley to tap the tech talent on the West Coast as it works to stay ahead of rivals like Kohl’s KSS and J.C. Penney JCP on the digital front.

That team has been behind some of the new tech ideas that Macy’s introduced in the last year or so, from its e-tailoring service with Men’s Wearhouse MW founder George Zimmer to an Amazon-like mobile application that helps a customer search for products on by submitting a photo of an item from real life. Macy’s is also testing services such as same-day delivery in some key markets.

But to do that means Macy’s needs top-notch talent, an abundant resource in Northern California yet paradoxically hard to obtain. (And certainly hard to relocate to the East Coast, where Macy’s New York offices are located.)
“I decided to leave in San Francisco [rather than move it to New York] because I’m competing for talent with Silicon Valley,” Macy’s chief executive Terry Lundgren said at the Consumer Goods Forum global summit in New York on Thursday.

Unlike many established tech companies—from eBay EBAY to Apple AAPL to Yahoo YHOO —Macy’s has kept its West Coast tech team in the heart of San Francisco rather than place it in Silicon Valley, a nod to the fact that more and more young tech workers want to be in an urban environment rather than an office park.

“Being in that new building in downtown San Francisco I put a big sign on it that said, ‘If you worked for you wouldn’t be driving past this building on your way to Silicon Valley right now,” Lundgren joked. The company is now ranked by Internet Retailer magazine as the No. 7 U.S. e-commerce retailer (last year its digital sales came to about $3 billion) and Lundgren said Macy’s is on pace to be No. 5 next year.

And Macy’s is not alone among retailers to fight for tech talent. WMT now has a team of 2,500 workers in San Bruno, near San Francisco airport, up from 500 just four years ago. The discount retailer’s e-commerce sales rose 22% to $12 billion last year, though the pace of growth slowed in the first quarter.

The Wall Street Journal reported last week that Walmart has lured 65 tech professionals from eBay. Indeed, head Neil Ashe said at a conference last week that the company lands 80% of tech workers it makes offers to.

“The people that we are competing with for talent are the people that you would expect, Google, Facebook, LinkedIn, Yahoo, et cetera,” Ashe said. “So we’re really, really pleased about that, and that’s allowed us to do this re-platforming exercise and it’s allowed us to scale.”

Other retailers with large teams on the West Coast include Kohl’s KSS and Target TGT , both based in the Midwest.

As for Macy’s, which reported a drop in comparable sales last quarter, powerful e-commerce is to keep growing in the United States, where retail sales have generally grown at anemic rates.

“The U.S. is not growing, so we have to figure out how to capture market share, how to create our new opportunities ourselves,” Lundgren said.