President Donald Trump has made shrinking the trade deficit a key goal of his trade battles.

The US trade deficit increased in July to its highest level since February.

The goods trade deficit with China and the European Union — two of Trump's main targets — hit record highs.

Soybean exports, one of China's main trade-war targets, fell in July.

President Donald Trump's trade war doesn't seem to have curtailed the American appetite for foreign goods — at least, not yet.

Despite the imposition of tariffs and counter-tariffs in July, the US trade deficit increased to $50.1 billion, a 9.6% increase from the previous month, according to the US Census Bureau.

The increase came on the back of a 0.9% increase in imports, to a record $261.2 billion, as US domestic demand remained strong. Exports, on the other hand, slipped 1%.

For the year, the trade deficit increased to $338 billion, compared with $316 billion in the first seven months of 2017.

Trump has repeatedly pointed to the US trade deficit as one of the primary reasons his administration has embarked on trade fights with China, the European Union, Canada, Mexico, and others.

But in addition to the overall deficit, the goods trade deficit with both China and the EU hit record highs in July:

The goods trade deficit with China increased to $36.8 billion as imports jumped 5.6% and exports tumbled 7.7%.

Similarly, the deficit with the EU hit $17.6 billion as imports ticked up 2.5% and exports collapsed 14.7%.

Ward McCarthy, the chief financial economist at Jefferies, said the worsening trade deficit with two of Trump's main trade war targets could lead to more attacks from the president.

"These record deficits are likely both be a partial consequence of the ongoing trade/tariff war and a likely catalyst for increase trade tensions between the US, EU, and China," McCarthy said in a note to clients.

McCarthy also pointed out that the trade deficit with Canada increased to $3.2 billion, a 58% increase from the month before and the highest since January.

Of note, exports of soybeans fell by $700 million in July, a 16.2% drop from June. Soybeans are the largest US agricultural export, and China is by far the primary destination for the crop. China imposed tariffs on US soybeans in July, and the pre-tariff surge in soybean exports appears to be reversing. But soybean exports through the first seven months came in above what they were in the same period a year ago.

The data shows that while the tariffs may be having some marginal effect on exports, the surge in imports is mostly due to the internal strength of the US economy. The consumer in the US is in a healthy financial spot, especially compared with those in many other countries, and the strong US dollar makes exports cheaper.

Add all of this up, and you have a recipe for a growing deficit.

Ian Shepherdson, the chief economists at Pantheon Macroeconomics, said that given the variety of factors at work, the second quarter's decline in the trade deficit would most likely be erased in the current quarter.

"The trade deficit likely will be flat to higher over the next couple of months, reversing most or all of the second quarter's drop, which the president has cited as evidence of the success of his trade policies," he said. "It wasn't."