Magnet attaches to a spoke, and sensor attaches to the fork. The position relative to hub/rim does matter in the sense that you adjust the gap between magnet and sensor that way. When placed closer to the hub, magnet will pass closer to the sensor as well. The correct distance between sensor and the passing magnet should be found in your computer's documentation. If not, a couple of mm is a good guess.