Malcolm Turnbull and his bruised colleagues have spent every day since the election blaming “Labor’s massive lie of the campaign” – the so-called Mediscare – for their poor showing. But in one of their few encounters during the eight-week slog, the prime minister had a different beef with Labor’s Bill Shorten. “Lay off my wealth,” he said to the opposition leader. “I know all about stereotypes,” an unsympathetic Shorten replied. “Your bunch keep branding me a union thug.”

Labor had clearly struck a raw nerve. According to the marketing analytics firm Ebiquity, the party spent more than $2 million on its “Seriously Out of Touch” advertising campaign – more than it forked out for its Medicare ads. For that part of their campaign, they mostly went below the radar of the mainstream media, using targeted material on digital platforms.

The “Out of Touch” message was, in the jargon of political theorists, “confirmation bias”. In other words, it was feeding into the perception of many voters that a multimillionaire resident of Sydney’s exclusive Point Piper couldn’t understand what it means to make ends meet when your wages have not kept pace even with low inflation, your job is insecure and your family struggles to pay its bills.

Despite some reports suggesting this was a light-bulb moment late in the campaign, nothing could be further from the truth.

Economist Richard Denniss, of The Australia Institute, has found a correlation between the seats that recorded swings away from the government and their socioeconomic demographic. He compares them to the profile of Wentworth, Turnbull’s seat. Not surprisingly, they could be on another planet when it comes to expenditure on tax advice, average negative gearing loss, unemployment and the percentage of people earning more than $87,000 a year.

But this is not simply class envy. It goes to the policy prescriptions and the framing of them that the government embarked on in its May budget and subsequent “Jobs and Growth” campaign. Denniss says this election finally buried the effectiveness of trickle-down economics. A huge swath of the electorate simply did not buy that if you give tax cuts worth $50 billion to huge corporations, and tax cuts to those earning above $80,000, the benefits will trickle down to them. Especially as, even on the Treasury’s own modelling, those benefits were 11 years away and were minuscule. The jobs Turnbull was talking about were not theirs.

Shorten attacked this prescription with laser-like accuracy. Why, he asked, should cuts to family payments, schools and hospitals, and further targeting of welfare, be used to fund the biggest and wealthiest? The question stuck because it played into a shifting sentiment. Research by the Australian National University has picked up a new mood in Australia, where a majority nominated as their preferred model a future based on community wellbeing rather than free enterprise or strong individualism.

And this leads to the potency of the “Mediscare”. Despite some reports suggesting this was a light-bulb moment late in the campaign, nothing could be further from the truth. An internal report on the strategy points out that Labor’s field and digital teams had been listening and learning from voters and gathering data and modelling on voters’ relationship to Medicare for two years. The party had put together a formidable digital team under the leadership of Erinn Swan, the daughter of former treasurer Wayne Swan. But the trigger to their research was the 2014 budget.

That budget, which foreshadowed huge cuts to Medicare and hospitals and tried to introduce a “co-payment” for doctor visits, struck at the heart of universality. Worse, it was widely seen as Tony Abbott brazenly breaking a solemn pre-election promise. In the very first week of the campaign, Labor promised to reverse Treasurer Scott Morrison’s extension of the freeze on doctor’s Medicare rebates. But still no one in the Liberal camp twigged that this was part of a crescendo in Labor’s campaign strategy. By the end of the campaign, Labor had promised $6 billion reversing the Liberals’ cuts to a raft of measures that would make healthcare – doctors’ fees, pathology, imaging and pharmaceuticals – more expensive.

The internal report says Labor’s digital team identified a pool of two million “persuadable” voters in target seats. During the eight-week campaign, these people saw online messages from the Labor Party, on average, 45 times each. This led to a high degree of engagement and interactivity. The ad featuring Bob Hawke was born of this strategy. Campaign director George Wright always intended to run it on television two weeks out from polling day.

The feather to fly with for the scare was the “privatisation” of the Medicare payments system, but if this was the “massive lie” that brought the Coalition government almost to its knees that claim is in turn a massive misreading of the deeper issue. As Richard Denniss says, it was emblematic of the concern of many voters, especially in lower-income seats. The most compelling example is Tasmania, where voters felt the Liberals cared more about their business mates than they did for them.

And to give an insight into how this message was reinforced, Labor ran rings around both the Liberals and the Greens on digital media. The report, confirmed by Dynatrace, which monitors online activity, says Labor content was shared nearly three times as often as other parties on Facebook, and retweeted 10 times as often on Twitter. On Facebook alone, this made up more than 100 million targeted impressions during the campaign.

After setting the tone as a sore loser in the early hours of Sunday morning, Turnbull reluctantly indicated on Tuesday that he had heard the message. “There was some fertile ground,” he said, “in which that grotesque lie could be sown. But we have to recognise that a material number of Australians were sufficiently concerned about our commitment to Medicare that they changed their vote.”

By midweek, though, it still seemed that Turnbull would form either a slim majority or minority government. Shorten was preparing himself for both outcomes, suggesting the prime minister was heading for a world of turmoil. “If Mr Turnbull does scrape home, his problems have only just begun,” Shorten said. “In the house of representatives he’ll be hostage to Mr Abbott and the right wing of the Liberal party, and in the senate he’ll be hostage to Senator Hanson elect and other right-wing senators.”

A foretaste of this pain began on election night. Andrew Bolt called for Turnbull to resign because he failed to deliver. Abbott’s former chief of staff, Peta Credlin, was excoriating in her assessment of the Coalition’s abysmal campaign and poor showing. She accused Turnbull’s allies who brought Abbott down of being a “hapless set of bedwetters”. She had no kind words for key plotters such as Peter Hendy, who lost the hitherto bellwether seat of Eden-Monaro to Labor, or for “Mr Canberra Games” Wyatt Roy, who lost his seat of Longman. In Eden-Monaro, there were signs that well-heeled Abbott supporters, such as mining magnate Gina Rinehart, refused to match their generosity of 2013.

In fact, the divisions tearing at the party generally since the September leadership coup seemed to have left it dangerously out of pocket. The Australian reported that midway through the campaign the Liberals were running so short of cash they went cap in hand to billionaire James Packer. Labor, by contrast, had raised $1.1 million online from small donors over the campaign. According to the internal report, Labor raised more than $2 million during the election cycle. The report proudly concludes: “This is the most an Australian political party has ever raised online during a campaign.”

Turnbull’s “I have a scream” speech on election night betrayed his anger and hurt. He was reluctant to even front the cameras. His difficulty coming to terms with a failure he blamed on Labor and everyone else, including the voters, had some of his closest allies worried. “The boss is in a bad place,” was the way it was put to me.

Some believe he is seriously considering following the example of Britain’s PM David Cameron and quitting. If the party won’t unite behind him, or believes he has failed to show the judgement needed to prosper, he may leave it to them to work it out for themselves. Who the party might turn to is highly problematic. Morrison was unimpressive in the campaign and is tarnished, as far as many conservatives are concerned, by his desertion of Abbott. Julie Bishop is also in the gun for her support of Turnbull last year.

A return to Tony Abbott is unlikely. Credlin dismissed the idea with a “why would he?” But stranger things have happened. Abbott proved hopeless dealing with the senate after the election he won in a landslide. How he could deal with the new and messier senate that includes Pauline Hanson, the woman he helped jail, is anyone’s guess. But other options are being discussed. Two cabinet ministers thought likely lads are Victoria’s Josh Frydenberg and West Australian Christian Porter.

Shorten is determined to add to the Coalition’s discomfort. Unlike the Abbott opposition, he will attempt to get crossbench support to legislate key agenda planks such as a banks royal commission should Turnbull fall into minority. Even if he doesn’t, there are sure to be enough numbers in the senate to put maximum pressure on an already weakened government.