Image copyright Getty Images Image caption Greggs - getting a taste for vegans

In a week of dismal news for retail, shares in Greggs hit an all-time high on the back of some savvy marketing and solid trading figures.

It's a turnaround from the spring when it issued a profit warning after freezing weather dented sales.

But it was the launch of a vegan sausage roll that propelled it into the headlines.

It was another example of how Greggs has harnessed social media to boost profits.

The marketing campaign - helped by a debate over whether the vegan product could be called a sausage roll at all - has been called "a master class in public relations" by the industry magazine PR Week.

The campaign was, crucially, delivered with a sense of humour and made no attempt to preach a vegan message.

Its Youtube advert parodied the tone of an iPhone commercial and garnered five million views on social media. But the marketing went far beyond a single video.

Image copyright Greggs/PA

Mock packaging

Journalists were sent vegan rolls in mock iPhone packaging and stores sold Greggs Christmas jumpers and sausage roll phone cases.

One journalist in particular supplied rocket fuel for the campaign.

In a tweet Piers Morgan, presenter of ITV's Good Morning Britain, said: "Nobody was waiting for a vegan bloody sausage, you PC-ravaged clowns."

Other celebrities reacted, there was an apparent demonstration against the rolls by Brexit supporters, which turned out to be nothing of the sort and there was an article in the Guardian suggesting a vegan sausage represented "a chance for a divided country to heal itself".

Then conspiracy theories emerged that Greggs had orchestrated everything.

Neil Knowles, the company's Digital Brand Communications Manager, denied any such manipulation: "You can never plan how the public will react.

"Whilst we always anticipated it to be huge news we never expected the reaction to gain as much momentum as it has done. And while we love a good conspiracy theory, we don't have any relationship with Piers Morgan."

Mr Knowles responded to Piers Morgan's outrage with the tweet: "Oh hello Piers, we've been expecting you".

John Brown, founder of the communications agency Don't Cry Wolf calls the campaign a "blueprint" for anyone in marketing, particularly the clever way that Greggs "stirred the pot".

"A lot of companies would be terrified of offending the vegan lobby so it takes a bit of guts to treat the whole thing as a bit of fun - for instance with the iPhone theme. A lot of vegans do own Apple products - that's a neat touch," he said.

Another crafty marketing trick also won admiration.

In May it launched a video of a Greggs team (masquerading as "Gregory & Gregory") successfully convincing foodies at a summer food fair that its Oriental Chicken Sticky Rice Salad was haute cuisine. It attracted a modest 50,000 views but got enthusiastic coverage in national and industry media.

Image copyright Greggs

The firm's marketing efforts struck a different chord at Christmas 2017 when its advent calendar put a sausage roll in a manger in pride of place.

Greggs apologised for putting the pastry in place of baby Jesus, with the three wise men gathered around it.

Christian Twitter users said the advert was disrespectful to their religion.

Weathering storms

The success of the vegan roll comes too late to appear in the company's latest trading update, which shows how Greggs has been weathering the worst storm to hit the retail industry in living memory.

The company has a history of doing well when others are struggling. Immediately after the financial crisis Greggs thrived as squeezed household budgets forced consumers to look for the lowest prices. The same is true now.

Image copyright Greggs Image caption Gregg's upgraded decor still feels comfortable to older customers

Diane Wherle, Marketing and Insights Director at consultancy Springboard said: "The store does two things well - its prices are really good and the quality is reliable. There's nowhere else you can get a good sandwich at that price."

Greggs was not always so dynamic. It started as a family business on the eve of the World War Two with John Gregg selling yeast and eggs and sweets on his bicycle to homes around Newcastle and it stayed small for a long time.

By 1964, and the death of the founder, it still only employed 15 people.

But the founder's sons and managing director Sir Michael Darrington started a rapid expansion buying out local competition and floating the company on the London stock market at 135p-a-share in 1984.

This week, after the trading figures were announced, the shares rose to 1,443p.

Ms Wherle said: "It has managed to cater to new markets without being overly ambitious. The builder can still come off the building site and get a hot pasty, but there are also salads - you'd never have got a salad in Greggs in the past. The decor is still recognisable even if it has been upgraded and the older traditional customers still feel comfortable."