How to control 2 DC Gearmotors with encoders

Hi, I have two of these I have Arduino UNO and Arduino Motor Shield to control the motors, but I don't know what's the pin connection for each dc gearmotor. By the way, I'm powering the arduino UNO with a 9[V] battery, and the dc gearmotors with 12[V] (8 AA batteries 1.5[V]). What would be the pin connection? and what's the code to control those motors?

Thanks in advance