The magnet will probably stick to the end of the shaft. You just need to find a way to make it stay there.
I used a short length of heat-shrink tubing around the shaft and magnet. The typical post for mounting a US Digital E4P encoder is just the right size for that. Perhaps a drop of an appropriate adhesive would work for you.