Coding image location under randomization

I am designing an experiment where the subject has to choose the right image by clicking the button that corresponds to its location. The images’ locations are randomized on the screen using trial variables applied to the image event. In order for me to identify if the response is correct and provide feedback, I need to know where the image was located.

If my location variable can change a code I can use that…otherwise, how can this be accomplished?