Bhagavad Gita · 9.23
येऽप्यन्यदेवता भक्ता यजन्ते श्रद्धयान्विताः।तेऽपि मामेव कौन्तेय यजन्त्यविधिपूर्वकम्॥
ye 'py anya-devatā-bhaktā yajante śhraddhayānvitāḥ te 'pi mām eva kaunteya yajanty avidhi-pūrvakam
Even those devotees who worship other gods with faith are actually worshipping Me alone, O son of Kunti, but not in the proper way.
— Bhagavad Gita 9.23
Source: Sacred-Texts.com (Sanskrit) + Bhagavad-Gita.io (translations)