The Deutschlandlied was the popular if unofficial anthem of Germany for decades from the 1840s on. As a Prussian concoction, Heil dir im Siegerkranz was never especially favored by the German public and was never the official German imperial anthem.
De facto, it was, since every German state had its own „state song“, some of them still extant. The Wiki article on it is okay
https://en.wikipedia.org/wiki/Heil_dir_im_Siegerkranz