It is pretty straight forward. Each settlement has an official religion. The percentage of the population that is of a different religion to the offical one acts as a penalty to public order.
The official religion is determined in this order.
1. If a shrine is built for a particular religion that is then the official religion.
2. If there is no shrine then the governor's religion is the official religion.
3. If the is no shrine and no governor then the faction leader's religion is the official religion.
Additionally if the governor and/or the faction leader's religion differs from the settlement's official religion you get additional penalties to public order...
Thus if you have a 90% pagan community and suddenly knock down their shrine and build a christian one, well you can see what will happen...
Bookmarks