The members of the tribe of Dan placed the idol in the city of Dan, establishing it as a god for their own idol worship [מצודת דוד, ביאור שטיינזלץ]. They set the idol up specifically for the purpose of ritual worship [מצודת דוד].
A clear timeline defines how long this idol worship lasted. During this era, the true house of God, which was the Tabernacle, was located in Shiloh [ביאור שטיינזלץ]. The idol remained standing in Dan from the very day it was placed there, continuing throughout the entire period that the Tabernacle stood in Shiloh.
This era of idolatry eventually came to a close when the Ark of the Covenant was exiled from Shiloh during the days of Eli. Afterward, when Samuel served as the judge over Israel, both the idol and its associated worship were finally removed from the land [מצודת דוד].