The US trade gap widened to a record in 2022, though expanding less than expected in December, government data said Tuesday, capping off the year on robust imports and strong spending.

The overall trade gap grew $103.0 billion from 2021 to $948.1 billion last year, showed Commerce Department data, on a surge in goods imports ranging from crude oil to consumer items including pharmaceuticals and household products.

This marks the biggest deficit according to government data dating back to 1960.

Analysts note that trade has been a swing factor in GDP growth over the last year, bogging it down in the early months of 2022 but providing a boost later on.

In December, the trade deficit expanded $6.4 billion to $67.4 billion, said the Commerce Department.

US imports rose $4.2 billion from November to December, hitting $317.6 billion on greater spending on consumer goods such as cell phones and other household goods as well as automotive vehicles.

Exports slipped $2.2 billion to $250.2 billion in December, dragged by a fall in goods exports such as industrial supplies and materials.

The latest figures come as households shift more spending to services instead of goods, with consumers grappling with persistently high inflation.

The deficit with China widened by $29.4 billion to $382.9 billion in 2022.

But the past year also marked the first time since 2019 that the United States imported more goods from the European Union than China.

Analysts believe this was affected by Beijing's strict virus controls and coronavirus outbreaks, which hit its economy last year, and an uptick in commercial activity elsewhere as countries bounced back from the pandemic.

- Reduced demand -

"Net trade has been a significant swing factor in headline GDP growth over the past year," said Ian Shepherdson, chief economist of Pantheon Macroeconomics in a recent note.

"It depressed growth in the first quarter of 2022 as an inventory-rebuilding frenzy by wholesalers and retailers led to a surge in imports," he said.

Trade provided a boost in the subsequent quarters as the surge unwound, but he added that similarly large swings in 2023 "are unlikely."

Matthew Martin of Oxford Economics added that the economy displayed solid growth in the fourth quarter.

But "underlying data points to softening activity, particularly for the world's major trade routes which have seen reduced demand from retailers and consumers," he warned.

Rubeela Farooqi, chief US economist of High Frequency Economics said that trade flows have also "slowed recently on a shift in demand for services from goods and weaker global growth."

"But better growth prospects in the US and abroad could provide support over coming months," she said.