Image copyright Reuters Image caption Data obtained by BBC Scotland gives an exclusive and rare insight into the world of "dark advertising" used during the General Election campaign

Political adverts are being targeted at specific Facebook users in Scotland, data seen by BBC Scotland has shown.

All the main parties appear to have been influencing voters with so-called "dark ads" - tailored messages visible to certain audiences.

The SNP and Lib Dems used ads focusing on pensions while the Conservatives and Labour targeted users in key seats.

The data, gathered by 'Who Targets Me' and the Bureau Local, is not exhaustive and relies on volunteers.

Last month the UK's Information Commissioner, Elizabeth Denham, launched an investigation into political adverts on social media and the "potential impact they have on an individual's privacy".

Traditionally the battle for votes has taken place in the open via billboards and pamphlets, knocking on doors, and pressing the flesh.

But in recent years there has been a significant increase in political advertising on social media platforms like Facebook.

According to the Electoral Commission, political parties spent a combined £1.3m on targeted Facebook advertising during the 2015 general election.

In Scotland the SNP spent £5,466, the Conservative and Labour parties forked out £29,502 and £7,153 respectively.

Just one year later in the 2016 Holyrood election, overall spending on Facebook ads increased by a third in Scotland with Labour alone nearly trebling their outlay.

And the appeal is obvious to political parties seeking to dent the SNP's stranglehold on the majority of Scottish constituencies.

Gold mine of personal data

Unlike traditional campaigning methods, advertising on social media means fewer boots are needed on the ground, and it allows parties to get a bigger bang for their buck in terms of eyeballs reached.

With an estimated 32 million users in the UK - many of whom will specify their age and gender, their ethnicity, where they live, as well as their interests and affiliations - Facebook is a gold mine of personal data.

This information allows parties an unprecedented opportunity to splinter their message - to tailor, tweak, personalise and craft their messages to very specific niches of the electorate.

But, unlike traditional posters or pamphlets, political adverts on social media are "dark" in the sense that only the intended audience will see the advert - our neighbours may very well see a different advert from the same party.

Image copyright SNP Image caption This SNP "dark ad" seems to have been targeted at Scottish volunteers with an average age of 61

The ads are extremely difficult to monitor and regulate because they appear on an individual's news feed rather than on public pages.

Ultimately only Facebook knows who is being shown what - but privacy obligations combined with commercial interests mean that information is not publicly accessible.

BBC Scotland was given exclusive access to a data set by the "Who Targets Me" group, which is collaborating with the Bureau Local - a part of The Bureau of Investigative Journalism.

For the first time we get an insight into the world of so-called "dark advertising" and how Scottish voters specifically have been targeted.

The SNP

Image copyright SNP Image caption This "dark ad" featuring the SNP's Mhairi Black seemed to target Facebook users in their 20s

The data shows that the party has run at least 18 unique adverts to date which have been seen 133 times across 36 constituencies.

These adverts:

warned that "pensions are not safe under Tories" and that the party would "always stand up for older people". They were seen by people with an average age of 61, with one particular ad seemingly striking a chord garnering more than 3,400 "likes" as of June 5

encouraged young adults in a pastel-rich video, hosted by the SNP's Mhairi Black, to "stop scrolling" and "be a voter and claim your future". This message was directed at Facebook users with an average age of 22, and was liked more than 2,600 times in four days;

told 66 would-be voters that the SNP would fight "Tory cuts"

alerted viewers that "the real cost of voting Tory" were child poverty, "squeezed" family incomes, and cuts to pensions

informed five Facebook users that "only the SNP can stop Tories here and break their obsession with an extreme Brexit".

The SNP did not respond to requests for comment on this story.

Conservatives

Image copyright Scottish Conservatives Image caption This Scottish Conservative "dark ad" also attacked the SNP on the issue of another referendum

Ads were run by different branches of the party - but only two of the seven seen by volunteers were sponsored by the UK party.

The data reveals these messages were seen 14 times across seven Scottish constituencies.

The data:

showed the two national ads warning several North East Fife constituents that Labour leader Jeremy Corbyn is a risk to security, and has "dangerous and nonsensical ideas"

revealed that the most viewed Scottish Conservative advert had this headline: "We said no. We meant it. Are you listening, Nicola". Readers were informed that the party "can take the threat of a second independence referendum off the table"

suggested that Conservative ads regarding independence seem to have only been pushed north of the border. A second advert stated that "only a vote for Ruth Davidson's Scottish Conservatives can stop Nicola Sturgeon's push for another referendum".

The Scottish Conservatives declined to comment on the number of adverts run, or their social media strategy.

Labour

Image copyright Scottish Labour Image caption This Scottish Labour ad featured a video attacking the SNP leader Nicola Sturgeon

The data shows that Labour had run at least 31 unique adverts to date, which have been seen 71 times across 26 constituencies.

These adverts:

showed that 60 views were of adverts from the UK party - these lobbied the electorate on issues such as fox-hunting and trains

revealed the remaining views were of ads run by the Scottish party which were seemingly filtered to focus on independence. One advert told users that the SNP leader should "drop her obsession with a divisive second independence referendum and instead [be] focussed on fixing the mess she has made of our schools".

A spokesman for the Scottish Labour Party acknowledged that Facebook was an "increasingly valuable campaign tool".

He added that the party had recently launched an advert which "directly targeted tens of thousands of Tory and Lib Dem voters in marginal seats across the country as part of a major new Facebook campaign, using the most up-to-date campaigning software".

Liberal Democrats

Image copyright Liberal Democrats Image caption The Liberal Democrat party seems to have been the only national party that attacked the SNP

According to the data the bulk of views - or "impressions" - were of adverts posted from the UK Liberal Democrats (206) - and leader Tim Farron's own Facebook account (33).

These adverts:

suggested it was the only party to have attacked the SNP with 11 Facebook users seeing this message: "Do you want to stop the SNP and block a second referendum? Only the Liberal Democrats can defeat the SNP in your constituency"

encouraged many volunteers to donate to the cause, with one advert stating that "for a limited time, every single pound you donate to our General Election campaign will be matched by a generous group of donors - meaning your money will go twice as far!"

were heavily focused on the issue of Brexit, and were seen most in the constituencies of Edinburgh East and Edinburgh South - areas which voted 72% and 77% respectively to remain in the EU. These adverts were primarily seen by men in their 30s. Most of the ads linked to a survey asking whether "Brexit has got you vexed"; a second stated that "Millions of EU citizens face the terrifying prospect of having to leave the UK after Brexit", and another warned would-be voters that "Theresa May's Conservatives are planning to rip Britain out of the Single Market without your say;

criticised the Conservative's so-called "dementia tax" with the ads targeting viewers with an average age of 45;

also revealed a focus on the NHS, internet regulation, and Theresa May's lack of condemnation of President Trump's withdrawal from the Paris Accords.

The Scottish Liberal Democrats did not respond to requests for comment on this story.

Call for advert regulation

Mark Shephard, a senior lecturer in politics at the University of Strathclyde, has researched the use of social media during the referendum and the 2015 general election.

He said he was "extremely worried" about the increase in political advertising on Facebook,

Dr Shephard said: "I think we're headed into a time of compartmentalization, a time when we're being fed a specific line.

"I think that's quite dangerous because it's important in a civilised society that we all see and debate, and are privy to, the same kinds of information and we can all then make informed choices."

Image copyright ICO Image caption UK Information Commissioner Elizabeth Denham announced her investigation into political advertising on social media platforms

Dr Shephard added: "And we already see with the manifestos, how they can be disaggregated into lots of different policy positions.

"So depending on your interest you can be targeted with the particular thing that might matter for you, but it's also important to know what else you're voting for.

"You might be most interested in what the dashboard in a car looks like, but you probably should pay attention to whether the tyres are pumped up, and whether the engine is running well."

Amid such concerns, the UK's Information Commissioner announced an investigation into political adverts.

While primarily focused on last year's EU referendum campaign, Ms Denham has stated the review will also examine adverts used during this election campaign.

A spokesman for the Electoral Commission said it was "continually developing" its understanding of online political ad campaigns, including through live monitoring.

He added: "We will report after the election on campaign spending, and on what changes to the regulatory regime may need to be made for future polls."

Image copyright AFP Image caption Data gatherer Louis Knight-Webb says in political ad terms the internet is "really quite lawless"

But "Who Targets Me" developer Louis Knight-Webb believed there was a shortfall between the watchdog's current regulations and rapidly developing technologies.

He said: "Party political broadcasts are highly regulated but the internet is really quite lawless and I don't think the regulators have been quick enough to catch up."

Mr Knight-Webb added: "If I isolate a group using the 'big five' personality traits and I work out for example that you are a neurotic person, I could send you a video of your house getting burgled, playing on your fears, and you may end up supporting that party.

"That's an extreme example, but it's something that could happen."

How is the data being gathered?

In the week the election was announced, "Who Targets Me" co-founders Sam Jeffers and Louis Knight-Webb created an extension for the Chrome web browser that could be downloaded and installed by the public.

This extension can grab meta-information - the message, date, numbers and types of reaction - from any political adverts it detects on the volunteer's Facebook news feed.

The tool reports not only any adverts to the user, but it also records it in a central repository.

To date, more than 10,000 people across the UK - 705 volunteers from all but one of Scotland's constituencies - have installed the extension, making the "Who Targets Me" dataset the largest of its kind.

What are the caveats?

because the project is reliant on installation by volunteers it does mean the advert data is skewed towards constituencies with greater numbers of volunteers.