" You gave him his heart's desire (Tehillim 21:3)
תַּֽאֲוַ֣ת לִ֖בּוֹ נָתַ֣תָּה לּ֑וֹ
You gave man free will so he can choose to do his heart's desires that You H'shem do not prevent man's lips from speaking any way he wishes. All this You did for man's good "for good blessings shall come to him" since man has free will and the evil inclination tempts him to sin, yet he overcomes his desires, H'shem sends him blessings and great reward through His divine Name, which is equal to the numbe3r 17 which is also the gematria of Tov. This is true even in the bitter exile where H'shem Name is in a state of katnus constriction. In the future, when H'shem's Name will be in a state of exalted expansion, surely there will be boundless rewards. And thus "Hodu L'Hashem ki tov -Praise His Name (Havaya) which equals tov" even in exile when His Name is constricted and equals 17 it is still tov, good "because His kindness endures forever" pg 108
MiPeninei Noam Elimelech
Our custom is to recite ha-gomel whenever one finds himself in a life-threatening situation and is saved by the grace of H'shem.
Examples: Attack by wild animals, what could have been a fatal car accident, terrorist/suicide attack, shooting attack, armed robbery, collapsed building, a soldier who saw combat in war. Ha-gomel is not recited when a person was merely close to the danger but was not actually involved in the danger itself.