Rotary encoder & sensor for DC motor

Hello everybody,

I've purchased 2 motors like this :

I'm studying asservissment (PID controller), i realized that i've not rotary encoder and no sensor.

Which component do i need to buy and can you explain me how to mount that ?
What is your advice for making asservissment (PID controller) ?

Thanks for your help.