With an encoder, what I normally do is establish a "birthplace" for the product, and accumulate the delta of the distance at regular intervals to know it's distance from that "birthplace". Then, for actuators, and other processes that are distance dependent, you can set them to operate upon ranges of that distance value.
Another method I have used for long conveyors or those with multiple entry and exit points is to use an encoder driven pointer to circle through an array representing a "map" of the conveyor contents. The pointer represents the beginning of the belt (or end) and all the actions and other necessary values are calculated as offsets (with rollover) from that pointer. This method is one of those that will puzzle people who look at the code, but it is nearly bulletproof in performance and you are only limited in size by how many arrays of data you can string together for your map. You don't have to shift and shuffle thousands of data points if, for example, you are tracking fifteen parameters of up to 40 different products on a 900 foot belt, they are all sitting there static in the map(s), you just keep sweeping through the map with your pointer and entry point offsets, diverter offsets, printer offsets, barcode readers, scales, whatever, they all come sweeping through the "map" data filling in the values as they go, or moving them to the next system in the case of diverters.
If you only have a handful of products in process at any given time, keeping a short list (array) of them and their distance from that one key "born here" sensor is pretty simple to write and read years later.