A rotary encoder cannot measure the position of a linear stage, at least not directly. What it actually measures is the position of the motor shaft. The linear position of the stage can then be calculated based on the pitch and diameter of the ballscrew. How closely the calculation matches the actual position of the stage depends on the amount of backlash and other mechanical error in the system.
To obtain the exact position of the stage, regardless of any play in the system, a linear encoder is needed. There are several types to choose from, but the most common is the optical linear encoder.