Hedera Posted December 18, 2012 Share Posted December 18, 2012 Hi, Can you please help me with Google Tag Manager. I need to insert a code before <body id="index"> Unfortunately I do not know how. I inserted in header.tpl and footer.tpl, but is is always shown after body tag in source code. Thank you for your help. Best, Ivan Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 18, 2012 Share Posted December 18, 2012 Hi, can you write here code of your header.tpl with google code? Regards Link to comment Share on other sites More sharing options...
Hedera Posted December 18, 2012 Author Share Posted December 18, 2012 Here it is (Google code is on top) in between {literal}: START OF THE DOCUMENT {literal} <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-F2AK" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-F5BK');</script> <!-- End Google Tag Manager --> {/literal} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang_iso}"> <head> <title>{$meta_title|escape:'htmlall':'UTF-8'}</title> {if isset($meta_description) AND $meta_description} <meta name="description" content="{$meta_description|escape:html:'UTF-8'}" /> {/if} {if isset($meta_keywords) AND $meta_keywords} <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" /> {/if} <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="generator" content="PrestaShop" /> <meta name="robots" content="{if isset($nobots)}no{/if}index,follow" /> <link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <script type="text/javascript"> var baseDir = '{$content_dir}'; var static_token = '{$static_token}'; var token = '{$token}'; var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals}; var priceDisplayMethod = {$priceDisplay}; var roundMode = {$roundMode}; </script> {if isset($css_files)} {foreach from=$css_files key=css_uri item=media} <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" /> {/foreach} {/if} <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> {if isset($js_files)} {foreach from=$js_files item=js_uri} <script type="text/javascript" src="{$js_uri}"></script> {/foreach} {/if} {$HOOK_HEADER} <script type="text/javascript" src="{$js_dir}cookies.js"></script> <script type="text/javascript" src="{$js_dir}script.js"></script> </script> <script type="text/javascript" src="{$js_dir}jscript_xjquery.jqtransform.js"></script> </head> <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> <!--[if lt IE 8]><div style='clear:both;height:59px;padding:0 15px 0 15px;position:relative;z-index:10000;text-align:center;'><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a></div><![endif]--> {if !$content_only} {if isset($restricted_country_mode) && $restricted_country_mode}<div id="restricted-country"><p>{l s='You cannot place a new order from your country.'} <span class="bold">{$geolocation_country}</span></p></div>{/if} <p id="back-top"> <a href="#top"><span></span></a> </p> <div id="wrapper1"> <div id="wrapper2"> <div id="wrapper3"> <!-- Header --> <div id="header"> <a id="header_logo" href="{$link->getPageLink('index.php')}" title="{$shop_name|escape:'htmlall':'UTF-8'}"> <img class="logo" src="{$img_ps_dir}logo.jpg?{$img_update_time}" alt="{$shop_name|escape:'htmlall':'UTF-8'}" /> </a> <div id="header_right"> {$HOOK_TOP} </div> </div> <div id="columns"> <!-- Left --> <div id="left_column" class="column"> {$HOOK_LEFT_COLUMN} </div> <!-- Center --> <div id="center_column" class="center_column"> {/if} END OF THE DOCUMENT Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 18, 2012 Share Posted December 18, 2012 In my opinion you can't insert it code outside body, because google code contains tag iframe and firebug(or another developer tools) will display it code into body tag. But if you view real source code (ctrl+u) you code will have correct location. Link to comment Share on other sites More sharing options...
Hedera Posted December 19, 2012 Author Share Posted December 19, 2012 Dear Alexynder thank you for your help. But still I do not understand where exactly to put it in order to be before body tag? Link to comment Share on other sites More sharing options...
Hedera Posted December 19, 2012 Author Share Posted December 19, 2012 Anyone?? Link to comment Share on other sites More sharing options...
Hedera Posted December 22, 2012 Author Share Posted December 22, 2012 Anyone? Link to comment Share on other sites More sharing options...
yaniv14 Posted December 22, 2012 Share Posted December 22, 2012 Like Alexander said, why do you want it outside <body> tag, Google specifically mention to insert the code immediately after the opening <body> tag, which mean inside the <body>. If you do want to insert a code before the <body> tag, you can just put it before </head>. 1 Link to comment Share on other sites More sharing options...
jasonhar Posted May 20, 2014 Share Posted May 20, 2014 FEI (For everyones Info) the code goes AFTER the opening <body> Link to comment Share on other sites More sharing options...
Luigi Massa Posted December 4, 2014 Share Posted December 4, 2014 Hi, there's this module http://addons.prestashop.com/it/analytics-prestashop-moduli/17472-modulo-google-analytics-report-with-google-tag-manager.html Link to comment Share on other sites More sharing options...
eec Posted July 20, 2015 Share Posted July 20, 2015 Has anybody come up with a solution to this matter yet? Link to comment Share on other sites More sharing options...
cilecek Posted July 21, 2015 Share Posted July 21, 2015 as jasonhar wrote only correct placement of GTM tag is right after <body> tag regards, milan START OF THE DOCUMENT <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR...D/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang_iso}"> <head> <title>{$meta_title|escape:'htmlall':'UTF-8'}</title> {if isset($meta_description) AND $meta_description} <meta name="description" content="{$meta_description|escape:html:'UTF-8'}" /> {/if} {if isset($meta_keywords) AND $meta_keywords} <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" /> {/if} <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="generator" content="PrestaShop" /> <meta name="robots" content="{if isset($nobots)}no{/if}index,follow" /> <link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <script type="text/javascript"> var baseDir = '{$content_dir}'; var static_token = '{$static_token}'; var token = '{$token}'; var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals}; var priceDisplayMethod = {$priceDisplay}; var roundMode = {$roundMode}; </script> {if isset($css_files)} {foreach from=$css_files key=css_uri item=media} <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" /> {/foreach} {/if} <link href='http://fonts.googlea...amily=Open Sans' rel='stylesheet' type='text/css'> {if isset($js_files)} {foreach from=$js_files item=js_uri} <script type="text/javascript" src="{$js_uri}"></script> {/foreach} {/if} {$HOOK_HEADER} <script type="text/javascript" src="{$js_dir}cookies.js"></script> <script type="text/javascript" src="{$js_dir}script.js"></script> </script> <script type="text/javascript" src="{$js_dir}jscript_xjquery.jqtransform.js"></script> </head> <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> {literal} <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-F2AK" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-F5BK');</script> <!-- End Google Tag Manager --> {/literal} <!--[if lt IE 8]><div style='clear:both;height:59px;padding:0 15px 0 15px;position:relative;z-index:10000;text-align:center;'><a href="http://www.microsoft...annercode"><img src="http://storage.ie6co...ar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a></div><![endif]--> {if !$content_only} {if isset($restricted_country_mode) && $restricted_country_mode}<div id="restricted-country"><p>{l s='You cannot place a new order from your country.'} <span class="bold">{$geolocation_country}</span></p></div>{/if} <p id="back-top"> <a href="#top"><span></span></a> </p> <div id="wrapper1"> <div id="wrapper2"> <div id="wrapper3"> <!-- Header --> <div id="header"> <a id="header_logo" href="{$link->getPageLink('index.php')}" title="{$shop_name|escape:'htmlall':'UTF-8'}"> <img class="logo" src="{$img_ps_dir}logo.jpg?{$img_update_time}" alt="{$shop_name|escape:'htmlall':'UTF-8'}" /> </a> <div id="header_right"> {$HOOK_TOP} </div> </div> <div id="columns"> <!-- Left --> <div id="left_column" class="column"> {$HOOK_LEFT_COLUMN} </div> <!-- Center --> <div id="center_column" class="center_column"> {/if} END OF THE DOCUMENT Link to comment Share on other sites More sharing options...
eec Posted July 21, 2015 Share Posted July 21, 2015 THANKS FOR THE COMMENT, It is fixed now, the issue was that; I missed the {literal} ... {/literal} from the beginning and end of the insert. putting that in place made it work. thanks, Link to comment Share on other sites More sharing options...
zenerry Posted September 30, 2015 Share Posted September 30, 2015 (edited) I added GTM code manually. Is there any way to check if GTM code is already working? Tag assistant doesn't seem to detect it. added: {literal} {/literal} Prestashop Ver. 1.4.8 Thanks in advanced. Edited September 30, 2015 by zenerry (see edit history) Link to comment Share on other sites More sharing options...
zenerry Posted October 1, 2015 Share Posted October 1, 2015 At the end I found the solution to make GTM code be detected by tag assistant and of course, working. It's really important that the given code to be placed between {literal} & {/literal} and leave NO spaces or "tabs" from the other code in header.tpl Hope it helps somebody... Link to comment Share on other sites More sharing options...
sduran Posted November 9, 2015 Share Posted November 9, 2015 Hi, i install the code of Google Tag manager in header.tlp and i have an error: HTTP response code indicates tag failed fire: Status 404 {literal} <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','XXXXXX');</script> <!-- End Google Tag Manager --> {/literal} Any help? My site is http://www.skyway.mx Link to comment Share on other sites More sharing options...
eec Posted November 9, 2015 Share Posted November 9, 2015 hi have done the steps mentioned on Google ? The ID should be set to your ID it should not be left as XXXXX, i guess it is in two places in the same phrase. Also it is important to exactly place the code after <body> opening tag, it can be a lengthy one like <body ........... ..... /> HERE the google code should be located starting with {literlal} check again and make sure all steps as written on google site are followed it should work. good luck Link to comment Share on other sites More sharing options...
atomointeractive Posted May 31, 2016 Share Posted May 31, 2016 Your Tag Manager status indicates 404 because your Tag Container is empty. You should add an analytics Tag & publish it.That´s done in your Tag Manager Console 1 Link to comment Share on other sites More sharing options...
softhightech Posted March 14, 2017 Share Posted March 14, 2017 just put your code inside {literal}your google tag manager here {/literal} Link to comment Share on other sites More sharing options...
oliiix Posted December 6, 2018 Share Posted December 6, 2018 It's an older thread so maybe this was good before, but nowadays: Tag manager code should be put in the HEAD tag, the further up the better. There's an additional but optional code that should be but right AFTER the body tag. But the main snippet goes into the head, not the body And especially not right before the body tag! Link to comment Share on other sites More sharing options...
oliiix Posted December 6, 2018 Share Posted December 6, 2018 On 3/14/2017 at 5:05 PM, softhightech said: just put your code inside {literal}your google tag manager here {/literal} Cool that you know a way, maybe be more specific about where and how to do so, so everyone could follow? Link to comment Share on other sites More sharing options...
dvd2org Posted November 24, 2020 Share Posted November 24, 2020 where is correct placement of GTM tag is right after <head> tag? --> <html{if isset($language_code) && $language_code} lang="{$language_code|escape:'html':'UTF-8'}"{/if}> <head> {literal} <!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer',xxxx');</script> <!-- End Google Tag Manager --> {/literal} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now