Hi Zac,
I'm working on the same task, not really sure how to do it either but I've come across this post. I've gotten the way to add the javascript but no clue on the rest.
https://stephanbruijnis.dev/posts/using-google-tag-manager-with-mendix/
Hope it helps.
I’ve not used GTM, but I have implemented HotJar successfully into a Mendix application.
To add HotJar, I created a Snippet that I could add to any page that needed the functionality. In that I added a JavaScript Snippet with the HotJar code.
Hope that helps