Detecting when the player kills a certain type of entity

I need to detect when a player kills a certain entity (which I could do very easily with an advancement) but the type of entity needs to be dynamic.
Continue to help post