Tag manager implemetion error

You actually don’t need to do any of that.

If you want to integrate Google Tag Manager on your Discourse site, all you need to do is add the container ID to the gtm_container_id site setting.