In your custom plugin init function
elgg_extend_view('page/default', 'myplugin/page/elements/tagmanager', 0);
Then create the view 'myplugin/page/elements/tagmanager' with that snippet
oh. I don't know how to do that?
There's no page I can just copy and paste into??
The usage of elgg_extend_view results in code of the view myplugin/page/elements/tagmanager being added to the view page/default. You could add the code to enable the Google Tag Manager to the file views/default/page/default.php directly. But this approach is discouraged because it will managing your site much more difficult later on (http://learn.elgg.org/en/2.0/guides/dont-modify-core.html).
Instead of adding the code directly to the original view file you can create a little plugin that deals with this modification (and possibly any other of these kind of modifications you might want to add at a later time). Creating such a plugin is not difficult. The bare minimum of a plugin is a manifest file and a start.php in the main plugin folder (http://learn.elgg.org/en/2.0/guides/plugins.html). You can look into the manifest.xml and start.php files of another plugin to have a starting point.
The start.php file only needs an init function with the single line of code posted by Matt above. And then you only need to create on additional file within your plugin at the location myplugin/page/elements/tagmanager.php and with this file you only need to add the code you would have added to an existing Elgg core file otherwise.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.