McDonald's (MCD -0.43%) is launching a massive new counteroffensive in the burger wars.

The fast-food titan is adding a new weapon to its arsenal -- mobile ordering technology -- that it believes will allow it to claw back market share from its rivals and stabilize its traffic trends.

Here's why it matters to customers and investors.

McDonald's at Ohio State University

Image source: McDonald's.

How does it work?

Customers will be able to order and pay for their food on their smartphones via the McDonald's mobile app. Using innovative geofencing technology, McDonald's can then determine when those customers are approaching its restaurants, thereby ensuring their food is prepared fresh.

Customers can choose to pick up their orders at the front counter or the drive-thru, where they can simply read their mobile order code to the crew and quickly pick up their food at the window.

There's even a new convenient curbside delivery option, which allows customers to skip the drive-thru line altogether.

When is it happening?

McDonald's began testing mobile ordering and payments in March in select U.S. markets, such as Monterey, California, and Spokane, Washington.

McDonald's plans to roll out mobile ordering to all of its 14,000 U.S. restaurants by the end of 2017. An additional 6,000 international locations in Canada, the U.K., France, Germany, Australia, and China will also receive the technology during that time, according to a press release.

Why is McDonald's doing this?

The impetus for McDonald's heightened focus on mobile technology can be gleaned from a statement by CEO Steve Easterbrook in another press release: "To deliver sustained growth, we have to attract more customers, more often."

For years, McDonald's has struggled with declining traffic. Fast-casual restaurants such as Panera (PNRA) have gained market share at the expense of fast-food chains. McDonald's has also ceded ground to direct fast-food competitors like Wendy's (WEN 0.86%), as well as "better burger" concepts such as Five Guys.

This heightened competition led to customer-traffic declines of 3% in 2015 and 2% in 2016. In all, McDonald's has lost about 10% of its traffic in the United States since 2012.

In response, Easterbrook and his team have focused on improving the quality of McDonald's food, including eliminating many artificial ingredients and using fresh beef in place of frozen in its famous Quarter Pounder hamburger.

And now, McDonald's believes that its new mobile ordering system will help to cut transaction times and reduce errors. It could also encourage higher average spending per consumer, as users will likely take more time to peruse McDonald's menu and customize their order, instead of feeling rushed at the register or in the drive-thru lane. Better still, the technology can free up workers who can be used to boost kitchen efficiency, and to provide more customer-friendly services such as delivering food to tables and curbside pickup locations.

What's the competition doing?

Starbucks (SBUX 0.29%) has long been the leader in mobile technology in the restaurant industry. Starbucks' Mobile Order & Pay service has proven overwhelmingly popular, leading to incremental sales even as overall retail traffic has fallen. In fact, less than two years after its nationwide rollout, already 8% of Starbucks' transactions are taking place through Mobile Order & Pay.

Panera is also investing heavily in digital technology. Its Panera 2.0 initiative is widely credited with helping to improve its guest experience and boost same-store sales. Its digital prowess also no doubt played a large role in Panera's recent acquisition at a hefty premium.

Yet -- fortunately for McDonald's -- fast-food chains have been slower to adopt these technologies, though that appears to be changing. Wendy's is focused on adding self-ordering stations at 1,000 of its restaurants by the end of 2017, but the company did recently say that it would be ramping up its mobile ordering platforms, which are currently only available in a few locations. Meanwhile, other burger chains like Burger King (a subsidiary of Restaurant Brands International) remain largely in the testing phase.

McDonald's aggressive move into mobile ordering could give it a powerful first-mover advantage over its rival fast-food burger joints.