"The Harper Conservatives didn't lose the 2015 election because of their stance on the niqab, which polling indicated was supported by a significant majority of voters.". Actually, I think that was a huge reason, but not directly.

At least 2/3 of the country wanted Harper gone and were deciding whether to vote for the Liberals or the NDP. In 2011, the NDP made huge gains in Quebec, vaulting them into official opposition status. But, Canadians are always hesitant to vote the NDP into power federally (probably lingering Ontario angst from the 90s).

Anyway, Harper's only hope was to split the "left" vote and the niqab issue was an epic fail on that front. The NDP came out and immediately denounced it, while the Liberals remained silent. The NDP then plummeted in Quebec (which was one of the provinces that most supported Harper on the issue).

So  the NDP took a hit in Quebec, and undecided voters who wanted Harper out stampeded to the Liberals, fearing that the NDP couldn't win.