Jump to content

Google Tag Manager


Recommended Posts

Posted

There are a few ways you can do this:

  1. Insert the code directly into the <head> and <body> sections (globalTemplate)
  2. 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
  3. 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:

edit-theme-code.png.2a0fc4bfeb47ecfadc8e22b526a9accc.png

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.

Posted

Google Tags Manager is now the the recommended method of installing Google Analytics on sites so it would be good to see 4.3 support it in the Analytics options list out of the box. 

As suggested above, I use the method of the standard Google Analytics code option for the header code and use a custom template for the opening body section code, then call it the Global Template. Seems to work okay. I also create additional templates for footerJS and headerstuff like extra RSS feeds, extra size favicons, font awesome 5 etc etc.

  • 4 months later...
Posted

Little odd that this isn't officially updated and supported yet since it been the preferred method for some time of installing Google Analytics. GTM is certainly not for those with a nervous disposition! For now, just use the methods described above.

Basically you can post the Google Tag header section code in the usual Google Analytics section, then manually add the 'body' section code into the globalTemplate as described above, just after the starting body tag so it looks like this:

</head>
	<body  blah blah blah...>
        EITHER INSERT THE BODY CODE HERE OR IF (preferable as the template won't be overwritten with the next update) YOU'VE PLACED IT IN A NEW CUSTOM TEMPLATE CALLED FOR EXAMPLE includeGoogleTMBODY, SIMILAR TO THIS LINE BELOW...
		{template="includeGoogleTMBODY" app="core" group="global" location="front" params=""}
        <a href='#elContent' class='ipsHide' title='{lang="jump_to_content_desc"}' accesskey='m'>{lang="jump_to_content"}</a> rest of template code...

 

 

Posted
On 3/4/2018 at 11:09 AM, The Old Man said:

Google Tags Manager is now the the recommended method of installing Google Analytics on sites so it would be good to see 4.3 support it in the Analytics options list out of the box. 

As suggested above, I use the method of the standard Google Analytics code option for the header code and use a custom template for the opening body section code, then call it the Global Template. Seems to work okay. I also create additional templates for footerJS and headerstuff like extra RSS feeds, extra size favicons, font awesome 5 etc etc.

You can still use global site tag and only use tag manager if you are using multiple tags on your site and want to control them from one place. I don't see a need to add google tag manager for just analytics. I do however see an opportunity for IPS to add the ability to use multiple analytics strategies and not just one. Right now I use google analytics and quantcast and just put their code one after the other in the settings section for analytics in Admin CP. From google analytics:

Global Site Tag (gtag.js) and Google Tag Manager are the recommended tracking methods for new implementations. Additional implementation options are also available including analytics.js and the Measurement Protocol. Learn more about additional tracking methods.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...