As the dust settles on Labour’s defeat, we must do better in understanding the causes. Too much analysis has been superficial and short term, rather than getting to grips with the bigger failings we must overcome to win next time.

A large missing part of that analysis concerns the way Ukip hurt us in Tory-Labour marginals by eating into our working-class support.

Contrary to the complacency among Labour’s campaign chiefs, until the last year – when Ukip was taking four or five Tory voters for every one Labour voter – in 2015 the Ukip share of the vote was higher in Labour-held seats than in Conservative-held ones.

I heard from candidates across the country who said this was happening in their areas. And the seat-by-seat analysis I’ve done confirms what they were saying.

We announced 106 target seats in 2013, the crucial majority of which were Conservative-held constituencies in England and Wales. To take these 85 seats, Labour needed an average swing from the Tories to us of 3.5% – higher in some seats such as Rugby, lower in others like Sherwood.

In the event, in these constituencies there was an average swing of 1.4% away from us to the Tories. A dreadful result on the night which meant we won only 10 of the 85 seats – little better than one in 10.

A big part of the problem was Ukip. In these 85 constituencies, Ukip was a minor player in 2010, polling fewer than 125,000 votes in total. This time was different. Ukip won over half a million votes, and added 10 percentage points to their average vote share.

In Labour seats where we suffered painful losses this was even starker – in Morley and Outwood, Ukip were up 13 percentage points, and in Corby they went from a standing start in 2010 to take 14% of the vote.

In two-thirds of the target seats we failed to take, the Ukip vote was greater than the Tory majority. And in constituencies where Ukip got a high share of the vote, the Tory to Labour swing was markedly weaker.

I saw this rising Ukip threat in my own South Yorkshire constituency, especially after the Rotherham by-election in 2012. And increasingly other Labour MPs talked to me of similar concerns. Ukip stepped into the space left by the Lib Dems as the anti-establishment, anti-politics party.

In response to and in the wake of last year’s European and local elections, I got Dr Matthew Goodwin, one of the co-authors of the excellent Revolt on the Right, to discuss Ukip with Labour MPs. And with Labour HQ staff I led work to produce a constituency Ukip risk report for our MPs in vulnerable areas, backed by one-to-one briefings. This was linked to a very good party working group that helped make sure Ukip was at last taken seriously throughout the party in the six months before the short campaign.

This work was important, and I know helped in some areas. But there is much more to do.

Following the election, Ukip have said that they want to replace Labour in the north, and with 120 second places across the country, they have a strong basis on which to build.

We know that Ukip support has increasingly been drawn from working-class voters. Where in 2010 this was barely apparent, in 2015 it is stark. On average across England and Wales, for every 10 percentage-point increase in the share of working-class voters in a constituency, there was a five percentage-point increase in Ukip support.

This suggests that Labour’s answer to Ukip cannot be purely tactical or about tinkering with policy. The causes of Ukip’s rise are economic and structural – at root, a reaction to the insecurity that globalisation and technological change have produced.

Labour’s response must be similarly broad-based and bold: an entrepreneurial industrial policy that creates good jobs; a regional policy that helps blue-collar areas which have suffered the most; an immigration policy that stops the exploitative use of migrant labour; and active trade unions to protect the pay and conditions of workers.

But the roots of Ukip support in working-class areas are also cultural. So above all, we need a Labour party active in all our local areas with Labour representatives who can be seen as authentic voices for all parts of the country. This is not a change that can be done to working-class communities, only with them.

Together, these can be the building blocks of Labour’s plan for blue-collar Britain that wins back working-class voters – and helps Labour win in 2020.