NurPhoto via Getty Images Facebook is launching a library of political ads targeted at Canadian voters that will be viewable and searchable online for up to seven years.

OTTAWA — Facebook is launching a new advertisement library that will capture detailed information about political ads targeted at voters in Canada, including who pays for them and whom they target.

The move is part of the social-media giant's response to changes the Trudeau government has made to Canada's election laws aimed at stopping bad actors — foreign or domestic — from interfering with Canada's upcoming federal election through advertising.

Bill C-76, which received royal assent in December, bans the use of money from foreign entities to conduct partisan campaigns.

Bill C-76 'consequential legislation': Facebook

It also requires online platforms, such as Facebook and Google, to create a registry of all digital advertisements placed by political parties or third parties during the pre-writ and writ periods and to ensure they remain visible to the public for two years.

Google recently said the demands of the new law are too onerous for its advertising system, which auctions ad space on the fly. It's simply refusing to take political advertisements in Canada around the upcoming election.

Kevin Chan, head of public policy in Canada for Facebook, says the company is trying to exceed the standards the Canadian law sets.

"C-76 is, in fact, very important and consequential legislation. It actually regulates online platforms, including Facebook," Chan said. "In order to comply we actually need to build new systems and new products to be able to do this, so right now we have our product-engineering teams working very, very hard between now and the end of June to ensure that we will be in compliance with what C-76 requires."