There are many rules on how to properly conduct yourself when visiting a temple or shrine. I'm going to let this link explain it to you in detail.
I tried my very best to abide by the rules and customs when I visited temples/shrines. This is me in Asakusa trying the purification fountain. You can find different types of fountains in each temples. I tried my best to photograph most of them which I will show you in another post.
At the purification fountain near the shrine's entrance, take one of the ladles provided, fill it with fresh water and rinse both hands. Then transfer some water into your cupped hand, rinse your mouth and spit the water beside the fountain. You are not supposed to transfer the water directly from the ladle into your mouth or swallow the water. You will notice that quite a few visitors skip the mouth rinsing part or the purification ritual altogether.
Pictures are also shown so you can follow along. I loved the whole experience!
P.S. I washed my hands but I did not drink the water ;)