i do not take th credit for this i just thought that some members may not know how to add tags like me so i will share it
There are a few ways you can do this:
Insert the code directly into the <head> and <body> sections (globalTemplate)
Create two new templates in your theme and paste each one into those templates, and place the template tag into the <head> and <body> sections
Use the Advertisements feature of the software and place the custom tags into the <head> and <body> sections
All of them require you placing some sort of tag into the globalTemplate. As an example for #1:
Find:
<title>{expression="output.getTitle( $title )"}</title>
{{if settings.ipbseo_ga_enabled}}
{setting="ipseo_ga"}
{{endif}}
Paste the code that goes into the header there, such as underneath the </title> and above the if statement.
Then find:
<body class='ipsApp ipsApp_front {{if isset( \IPS\Request::i()->cookie['hasJS'] )}}ipsJS_has{{else}}ipsJS_none{{endif}} ipsClearfix{{foreach output.bodyClasses as $class}} {$class}{{endforeach}}' {{if output.globalControllers}}data-controller='{expression="implode( ',', output.globalControllers )"}'{{endif}} {{if isset( output.inlineMessage )}}data-message="{expression="output.inlineMessage"}"{{endif}} data-pageApp='{$location['app']}' data-pageLocation='front' data-pageModule='{$location['module']}' data-pageController='{$location['controller']}'>
Paste the body code directly underneath that.
The other two ways of doing it are pretty much the same thing, only they require a couple of extra steps. I personally just created a template for each and then called the templates in the spots I mentioned above, such as:
<head>
<title>{expression="output.getTitle( $title )"}</title>
{template="google_tag_manager_head" app="core" group="global" location="global" params=""}
{{if settings.ipbseo_ga_enabled}}
{setting="ipseo_ga"}
{{endif}}
...
<body class='ipsApp ipsApp_front {{if isset( \IPS\Request::i()->cookie['hasJS'] )}}ipsJS_has{{else}}ipsJS_none{{endif}} ipsClearfix{{foreach output.bodyClasses as $class}} {$class}{{endforeach}}' {{if output.globalControllers}}data-controller='{expression="implode( ',', output.globalControllers )"}'{{endif}} {{if isset( output.inlineMessage )}}data-message="{expression="output.inlineMessage"}"{{endif}} data-pageApp='{$location['app']}' data-pageLocation='front' data-pageModule='{$location['module']}' data-pageController='{$location['controller']}'>
{template="google_tag_manager_body" app="core" group="global" location="global" params=""}
The method of using the Advertisements feature means you can select which usergroups the Javascript runs for (depending on what you're doing with Google Tag Manager). For instance, if you don't want it to load for Admins, you could use that option. Or just use an IF statement and wrap it around your code.
not mine