Amid a pandemic and days of protests over racial injustice, multiple states are holding primary elections on Tuesday (follow the results and our live analysis here), including the key presidential battleground of Pennsylvania.

In Philadelphia, voters at both Finley Recreation Center and Anna B. Day School, in the predominantly black East Mount Airy neighborhood, reported morning wait times of 90 minutes to two hours, as some voting machines broke and people had to cast ballots provisionally.

Many just left.

But for groups that are trying to get people to sign up to vote by mail in November, this primary election was the perfect opportunity, one that doesn’t come around often.

For some of the people who showed up — even if they didn’t vote — an ad from three civil rights groups would soon be sliding onto their smartphones. The ad campaign, created by the organizations Make the Road Action, One PA and Casa, asked simple questions about the in-person voting experience, and linked users to more information on how to vote by mail in November.

The groups were able to reach voters through a digital advertising tactic known as geofencing that allows advertisers to pinpoint a specific location, set a radius around it and serve ads on social media and other platforms to anyone who crosses into the location.

“People will go to vote, they’ll get frustrated and see how frustrating it is to vote in person, and then we’ll send them digital ads where they can now request their ballot to vote by mail for the general election in November,” said Ivan Garcia, the political director for Make the Road Action in Pennsylvania. “We want to do it while voting is still fresh in their mind.”

Tactics like these may be helping Democrats and left-leaning groups open an advantage in mail-in voting registrations, while some Republicans fear that President Trump’s false attacks on mail balloting may be dissuading voters in their own party from signing up.

The initial plan was to link to Pennsylvania’s mail-in ballot application form directly from the ads, but the state temporarily removed the application on Tuesday. So the groups’ ads instead direct people to a survey that collects details about their voting experiences, like lines, wait times, identification requirements and whether there was proper personal protective equipment at polling locations.

As soon as the vote-by-mail application is back online, those who filled out the survey will be sent an ad encouraging them to vote by mail.

Other groups are mounting similar plans for upcoming elections. In Georgia, which holds its elections next Tuesday, the left-leaning voting rights group Vote From Home 2020 will be using a similar geofencing tactic.

“We are going to geotarget polling locations in majority-black neighborhoods,” said Suzy Smith, the group’s co-founder. “We want to speak with people who are in line to vote and provide them with an option to request mail-in ballots for the November general election.”

Whenever possible, the ads will link to a mail-in ballot application — “We want people requesting ballots while they wait,” Ms. Smith said — but the group will also be able to retain a list of those who voted in person and target them with future advertisements.

The geofencing advertising tactic has proved to be useful for political campaigns, particularly those with smaller budgets. Thanks to its sophisticated targeting, the total number of impressions — meaning anyone who interacted with the ads — is often quite low, which keeps the price low.

In the lead-up to Wisconsin’s elections in April, which were held amid stay-at-home orders during the coronavirus outbreak, strategists working on down-ballot races — like a city alderman’s race in Milwaukee — struggled with the out-of-the-box geotargeting maps offered by companies like Facebook.

So Sachin Chheda, a Democratic political operative, uploaded a list of addresses that were in the alderman’s district, then targeted mobile devices that were within 50 feet of those addresses, essentially creating a targeted map for the district.

Campaigns are also relying heavily on other digital tactics to get out the vote for the decidedly analog process of voting by mail. In Pennsylvania, the state Democratic Party has been hosting virtual phone banks and texting drives nearly every day for weeks, encouraging people to vote by mail and then tracking them through the process. It’s known as a ballot chase program.

Using the state party’s voter file, volunteers from across the country are able to call or text voters in Pennsylvania to ask whether they’ve requested a ballot. An app with a call script provides volunteers with responses based on how far along a voter is in the absentee process.

For the past week and a half, Democrats in the state have focused their effort on contacting voters who have already requested a mail-in ballot but have not yet returned it, and then letting them know their remaining options for returning the ballots.

But for those who chose to vote in person on Tuesday and were faced with extensive lines (and perhaps a lack of social distancing), Ms. Smith sees an easy message to sell: “Skip the line, vote by mail in November.”