New first rule in politics. Never answer a text message from Tom Watson.

I made this rookie mistake at a PLP meeting almost six weeks ago and ended up spending the next month in Oldham.

It was when I got up there that I got some idea of the enormity of the task ahead of me.

For five weeks, people traipsed the icy streets of Oldham selling the Labour message, while I went to focus groups, shaped our message, and worked closely with our national headquarters and our remarkably effective regional office led by the wonderful Anna Hutchinson. I feel I owe it to the tireless campaigners who arrived in their hundreds, day in, day out, to tell the story of how we fought the campaign and won such a wonderful victory on behalf of all Labour members.

There are lessons to be learned for the party, and I will certainly be taking my experiences back to my own seat only six miles south from Oldham. This is the story of how we did it.

Our plan started with a discussion with Ian Warren, a freelance campaign guru who advised the party on the UKIP threat in the 2015 general election. Ian had also previously worked for UKIP so knows how they tick. Ian’s message was very simple: UKIP would fight a campaign based on Corbyn and Labour being out of touch, and on immigration, and that we had to earn the right to be listened amongst people who like Labour values but who do not quite believe that we stand up for people like them anymore. We had to lessen the impact of the softness of our support when it came to issues like immigration by focusing relentlessly on our strengths.

We needed to persuade people that we were not only on their side when it came to issues like jobs, investment and training, but that we had credibility when it came to delivery. Polling suggests our lead on being on the side of ordinary people is far higher than our perceived ability or willingness to deliver.

To this end, we focused on Jim’s rock solid record of delivery in Oldham. People could see a tangible legacy of his time leading the council.

From listening to people, it was clear that there was a latent feeling that Oldham had come some way forward since the race riots fourteen years ago. It was by no means a model community just yet – they all accepted that – but there had certainly been progress, and many people were concerned that it could easily go backwards, undoing the hard work of all of those local leaders who had contributed so much.

This is where UKIP made their first unforced error.

Oldham Council is in the process of turning their old town hall into a multiplex cinema and some restaurants, which will mean Oldham is no longer the only metropolitan borough in Greater Manchester without a cinema. The town hall was a symbol of civic pride – but had become hopelessly dilapidated and surplus to requirement after the Council moved into the new civic complex forty-odd years ago. John Bickley, the UKIP candidate, condemned the building of the new cinema, and to this day I still do not know why.

This allowed us to begin framing the battle as being fought between a local man – a man of action – with a track record of delivering key projects and the jobs that come with them, and an outsider with no real connection to the town, who could do little but snipe from the side lines. It also showed a profound failure of Bickley to understand the challenges facing the town.

We had our message – the emphasis on the election being a choice between a man with a track record of delivery for Oldham, and an outsider with nothing to contribute beyond negativity.

The second crucial part of our campaign was the delivery of the message, and this came in the form of extremely sophisticated targeting, both with direct mail and doorstep canvassing.

Every single elector had at least one piece of literature from us, and key voters had many more. We had five key ‘ambassadors’ for our campaign. We had Maggie, a local pensioner. We had Peggy, a stall holder on the local markets. We had the Chairman of Oldham Athletic Football Club, and the secretary of the local council of mosques. And we had the Franklins, a young family from Oldham. We segmented every voter into groups with similar backgrounds and interests, and we sent letters from each of our key endorsers to those groups that their message may have resonated with. For example, those young families that would likely have received tax credits had a letter through their door from the Franklin family.

Our Get Out The Vote (GOTV) effort was remarkably effective, which we can attribute to it being absolutely relentless.

We had three rounds of canvassing in total. Our first round focused on every individual that had ever voted in any election, regardless of political history. Our second round of canvassers visited those voters that had either remained uncontacted from the first round, or who had told the first canvassers that they might be supporting Labour, were still undecided, or wouldn’t say. Our third and final round of canvassing, most of which was done in the final week, was focused on firming up the weak Labour vote.

Our GOTV message was stridently confident – ‘I back Jim’. It featured local people and organisations putting themselves firmly behind our candidate, which created the impression of unity and a moment of rare agreement. This contrasted strongly with the UKIP message – ‘Bickley Backs Britain’. This was another opportunity to demonstrate that UKIP were hopelessly out of touch with those crucial local issues, like jobs and infrastructure. Our only negative campaigning was to point out that the UKIP candidate was not local. People recognised the positive nature of our campaign, and were not impressed by the other parties’ petty attacks on Jeremy Corbyn, which did not really cut through. We featured Corbyn on two prominent leaflets, and there were plans for him to ask a question from an Oldham voter in the final Prime Minister’s Questions before polling day, sadly scrapped due to the Syria debate.

This message was very effective. Our data consistently showed that of everybody who told us they were voting Labour before the general election, eight in ten were supporting us again. But – here is the crucial part – we were actually winning over substantial numbers of people who told us before the last election that they wouldn’t be supporting us. This explains our increased vote share.

There is one absolutely fundamental lesson we must learn from the Oldham West and Royton by-election.

I believe UKIP is attempting to become the Scottish National Party of northern England. In Scotland, we took our vote for granted, and we paid the price. We cannot let the same thing happen to our northern heartlands. We have to halt the malaise in northern seats, and work every single constituency like a marginal. It is about reconnecting, and earning the right to be heard through hard work and a track record of delivery through local councils. This is what won it in Oldham, and I see no reason for that success not to be replicated across the north in 2020 – as long as we all put the work in.

Andrew Gwynne is MP for Denton and Reddish, and took the political lead on organising for the Oldham West by-election.