Stats system

I want to make a datapack where players level = their stats. But I don't really understand how I should detect when a player levels up (it's for a map that I will surely never make, I just want to learn)
Continue to help post