Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Mercury Forever Posted March 2, 2018 Posted March 2, 2018 I need to add a Google TAG MANAGER code in the HEAD and BODY section, some experience or guide. https://www.google.com/analytics/tag-manager/?hl=es
Cemmos Posted March 2, 2018 Posted March 2, 2018 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.
The Old Man Posted March 4, 2018 Posted March 4, 2018 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.
blacknight Posted July 10, 2018 Posted July 10, 2018 Any news about Google Tag manager implementation? I would like to use it too. What is the best way to add it to IPB?
The Old Man Posted July 10, 2018 Posted July 10, 2018 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...
AlexWebsites Posted July 15, 2018 Posted July 15, 2018 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.