Adding markers to naturally spawning entities

Hello I would like to know what is a good way to effectively tag all naturally spawning entities of a particular mob type so that once that mob is killed by a PLAYER you can run certain commands at that location. (kinda like baby slimes spawning when a slime is killed, but for other mobs) One way I can think is to just use markers riding the mob and detecting when it's no longer present to run a command. But how can i add markers to all naturally spawning entities and will this cause performance issues? IF yes what is a better way? Bonus: And how can i make sure it acts only when the player kills the mob?
Continue to help post