Do you have Episerver AlloyTech template website? There, you can find PageContextActionFilter and if you follow the code, you can see how a property on a PageViewModel gets set based on some rule.
I believe that's what you are looking for, but if not, then it would be good to explain when and where you want to you want to render the code.
I can't seem to figure out where I can embed the codes so they will pop up on selected pages?
I'm pretty new in this game, so please bear with me :)