You'll probably want some kind of flexible coupler for that style of encoder, as unless you can guarantee very accurate alignment, you'll likely kill the encoder pretty quickly.

An encoder with a separate disc/reading head would of been a better choice for mounting directly onto a shaft.