On Tuesday, Walgreen (WBA -1.15%) -- which operates the largest drugstore network in the country -- reported adjusted EPS of $0.85 for its fiscal third quarter. Adjusted EPS grew 18% compared to the prior year, when Walgreen was suffering from a dispute with pharmacy benefits manager Express Scripts (ESRX). Nevertheless, Walgreen missed the analyst consensus for earnings, sending shares down more than 6% on Tuesday.

WAG Chart

Walgreen 1 Week Price Chart, data by YCharts

While analysts were expecting higher earnings based on a higher profit margin, Walgreen shares appear to have overreacted to the miss. The company stated that it is on track to reach $125 million to $150 million of synergies this year from its combination with European pharmacy group Alliance Boots. That is at the higher end of the original guidance. Furthermore, Walgreen is increasingly winning back customers who moved prescriptions to competitors like Rite Aid (RAD 24.00%) and CVS Caremark (CVS -1.25%) during the Express Scripts dispute.

Most importantly, Walgreen is about to start reaping the benefits of its Balance Rewards program, which it introduced last September. In less than a year, Walgreens has signed up more than 75 million customers, putting the program on par with CVS' ExtraCare Rewards program. This allows the company to track customer purchases and gain insight about customer behavior. Moreover, the rewards structure tends to encourage repeat visits, which should boost customer traffic and sales going forward.

Turning the ship around
It takes time to change consumer habits, so many of the Express Scripts customers who had to find other pharmacies during the first half of 2012 have not yet returned to Walgreens. Nevertheless, the company has posted strong growth in prescription numbers recently, with comparable store prescription count growing 7% last quarter. By contrast, Rite Aid saw a 0.1% decline in that metric during the same period (CVS reports results on a different cycle).

Thus, prescription business is clearly starting to come back. However, Walgreen continues to have weakness in the "front-end," i.e., non-prescription sales. After four straight quarterly declines in comparable-store front-end sales, the company posted a meager 0.4% increase last quarter. The weakness was partially due to lower promotional behavior, which the company has recently reversed.

Loyalty program benefits ramping up
However, Walgreen has laid plans that should help it regain most of the business it lost over the next several quarters. For the past nine months, the company has focused on signing up as many customers as possible for its new loyalty card, Balance Rewards. Walgreen was the last of the three major drugstore chains to introduce a loyalty card. CVS launched its ExtraCare Card in 2001, and Rite Aid introduced its wellness+ card in 2010.

Senior executives at Walgreen are very excited about the potential to use the loyalty program to drive higher front-end sales going forward. For the past year, the loyalty program has been a drag on earnings, due to the necessary IT investments, and the labor involved in signing up 75 million customers.

However, the data generated by loyalty card use is starting to give Walgreen insight into how to boost sales through targeted investments in marketing or promotions. Moreover, now that customers have had time to accumulate points, they will be receiving rewards that will drive additional store traffic.

Foolish bottom line
While Walgreen suffered a setback due to last year's dispute with Express Scripts, the company is primed for a big-time comeback. The company already achieved record EPS this quarter. As more customers return from other pharmacies, Walgreen's prescription growth should continue to outpace the industry's. Moreover, a return to promotional initiatives, and the ramping up of the company's new loyalty card, should start to drive significant front-end sales increases soon. As a result, Walgreen looks like an enticing investment opportunity after its recent pullback.