How to /testfor snowball a snowball hitting the ground or mobs? [duplicate]

I decided to make a snowball grenade, but I stuck at how to /testfor the snowball when it hits a mob or the ground. Is there a scoreboard command that can help me? For example

 /scoreboard players set @e[type=snowball] hit 1 {onground:1b}

Solution 1:

Constantly teleport an invisible entity to the snowball. Execute off of the invisible entity and test for the snowball. If it's not there, it's hit the ground.