Just in time for the flag-waving July 4 holiday, a new study ranks Utah as America’s fourth most patriotic state. But it likely could have been No. 1 if more Utahns voted — or chose to serve in the military.

The study released Monday by Wallethub compared the states on what it considers 13 key indicators of patriotism.

Utah ranked No. 1 in four categories: volunteer rate, volunteer hours per resident, share of residents who participate in groups or civic organizations and its civics education requirements. It also ranked No. 2 in AmeriCorps volunteers per capita.

Where it really fell down is a category considered as extra important, which was triple-weighted to award a quarter of all possible points: the share of adults who voted in the 2016 presidential election.

Utah ranked No. 23 in that category, after 62.68% of adults cast a ballot.

Source: WalletHub

Of course, that was a controversial year when the major candidates were not overly popular in Utah. While GOP presidential candidates in recent decades have won overwhelming majorities in Utah, Republican Donald Trump won only a plurality in the state, with 45.5% of the vote. Democrat Hillary Clinton followed with 27.5%, independent Evan McMullin won 21.5% and 18 other candidates split 5.5% of the vote. Many Utahns simply didn’t vote.

It wasn’t just low voting rates that hurt Utah in the new rankings.

"Aside from the share of residents who voted in the last presidential elections, there are other metrics in which Utah could use some improvement,” said WalletHub analyst Jill Gonzalez.

“For example, the state has very few veterans. The average number of military enlistees is also among the lowest in the country, as is the number of active duty military personnel and the number of Peace Corps volunteers."

Utah ranked No. 46 for veterans per 1,000 adults; No. 38 for the rate of military enlistees over the past five years; No. 32 for its rate of active duty military personnel; and No. 38 for Peace Corps volunteers. It did manage to rank a respectable No. 9 for its share of adults who serve in the military reserves.

New Hampshire was ranked the nation’s most patriotic state, followed by Wyoming and Vermont.

At the bottom of the rankings, New Jersey was considered the least patriotic followed by New York and California.