This hymn is found in the Ganesha purāna. It is taught to lord Shiva by lord Ganesha himself. The story is given in detail in poorvapeethika that when lord Shiva wanted to destroy the tripurāsura – the demon king with three flying cities, but could not succeed even after enormous efforts, lord Shiva meditated on Ganesha. Then Ganesha appeared before Shiva in his five faced form (panchamukha Ganesha) and initiated lord Shiva with this hymn.
This hymn is one amongst the powerful hymns on lord Ganesha and it has great importance in the Gānāpatya tradition.
This book explains the poorvapeethika, phalashruit of ganesha sahasranama, Explains nyasas, dhyana, gives ganesha sahasranama stotra, Ganesha Sahasranamavali, and Tarpana vidhi in legible font
Ganesha himself teaching us the method of doing archana and tarpana, he says
In the fourth day of shukla paksha of Bhādrapada month (which usually which falls in August and September of the Gregorian calender), on the date of my birth, my devotees shall worship me by offering a pair of doorva grass reciting each name of the sahasranāma stotra and then do the tarpana ritual as prescribed by the scriptures. All their desires are fulfilled, they are blessed with wealth, food grains, yogic powers, victory and fame.