WASHINGTON — Commuters on the sea-hugging Montauk line of the Long Island Rail Road had a shared experience while browsing the Internet on their smartphones recently: A half-screen ad popped up attacking Representative Timothy H. Bishop as “one of Congress’s most corrupt” members.

Yet some might have already seen Mr. Bishop — a Democrat facing the Republican challenger Lee Zeldin in New York’s First Congressional District — in another ad attacking him had they perused YouTube that morning. The familiar face may have also greeted them at work, where they would have viewed anti-Bishop display ads while browsing news sites. And there he was again on their phones on the way home, even as they crossed in and out of their congressional district.

The digital track and chase in eastern Long Island — part of the National Republican Congressional Committee’s effort to catch up with Democrats’ sophisticated voter targeting — is an integral part of the modern ground game. Now campaigns know where you eat, what you watch, what you read, where you work, if you commute — and are tracking it in real time, delivering specifically tailored messages to individual voters and hounding them until the ballots are cast.

And in an election cycle with so many close races, the outcome, with control of Congress at stake, may turn on which party does the better job of, in effect, engineering the vote.