Baldomero Gar
Gamma
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
- Desde
- 23 Abr 2019
- Mensajes
- 223
Buenos días. ¿Alguien sabe cómo puedo meter el siguiente código de Analytics G4 en el header.tpl de mi tienda prestashop sin que se rompa?
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KSLYYLYCC1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-KSLYYLYCC1');
</script>
EL código fuente del header.tpl es este:
{*
Version: V1.0.2
Modificated: 2019-09-05
Author: xxxxx
*}
{block name='head_charset'}
<meta charset="utf-8">
{/block}
{block name='head_ie_compatibility'}
<meta http-equiv="x-ua-compatible" content="ie=8">
{/block}
{block name='head_seo'}
<title>{block name='head_seo_title'}{$page.meta.title}{/block}</title>
<meta name="description" content="{block name='head_seo_description'}{$page.meta.description}{/block}">
<meta name="keywords" content="{block name='head_seo_keywords'}{$page.meta.keywords}{/block}">
<meta name="robots" content="{$page.meta.robots}">
{if $page.page_name ="product"}
{assign var=img_social_share value=$product.cover.bySize.large_default.url}
<meta property="og:image" content={$img_social_share} />
{/if}
{if $page.canonical}
<link rel="canonical" href="{$page.canonical}">
{/if}
{/block}
{block name='head_hreflang'}
{assign "alternative_langs" $urls.alternative_langs|default:[]}
{foreach $alternative_langs as $code => $pageUrl}
<link rel="alternate" href="{$pageUrl}" hreflang="{$code}">
{/foreach}
{/block}
{block name='head_viewport'}
<meta name="viewport" content="width=device-width, initial-scale=1">
{/block}
{block name='head_icons'}
<link rel="icon" type="image/vnd.microsoft.icon" href="{$shop.favicon}?{$shop.favicon_update_time}">
<link rel="shortcut icon" type="image/x-icon" href="{$shop.favicon}?{$shop.favicon_update_time}">
{/block}
{if $page.page_name == 'index' && $djv_flags.template.opinions.trustivity}
<link href='//www.trustivity.es/css/style_widget_trustivity.css'
rel='stylesheet' type='text/css'>
{/if}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&display=swap" rel="stylesheet">
<!--link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous"-->
{block name='stylesheets'}
{include file="_partials/stylesheets.tpl" stylesheets=$stylesheets}
{/block}
{block name='javascript_head'}
<script>var djv_project = '{$djv_project}'; </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
{if $djv_flags.template.gtm.id}
<!-- 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','{$djv_flags.template.gtm.id}');</script>
<!-- End Google Tag Manager -->
{/if}
{include file="_partials/javascript.tpl" javascript=$javascript.head vars=$js_custom_vars}
{* TODO: Cargar solo si esta definido en variable de plantilla *}
{*include file='_partials/javascript-'|cat:$djv_project|cat:'.tpl' javascript=$javascript.head vars=$js_custom_vars*}
{/block}
{block name='hook_header'}
{$HOOK_HEADER nofilter}
{/block}
{block name='hook_extra'}{/block}
<meta name="facebook-domain-verification" content="fki799u2ilw1twnjx30giavgr5qnns" />
¡MUCHA SGRACIAS!
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KSLYYLYCC1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-KSLYYLYCC1');
</script>
EL código fuente del header.tpl es este:
{*
Version: V1.0.2
Modificated: 2019-09-05
Author: xxxxx
*}
{block name='head_charset'}
<meta charset="utf-8">
{/block}
{block name='head_ie_compatibility'}
<meta http-equiv="x-ua-compatible" content="ie=8">
{/block}
{block name='head_seo'}
<title>{block name='head_seo_title'}{$page.meta.title}{/block}</title>
<meta name="description" content="{block name='head_seo_description'}{$page.meta.description}{/block}">
<meta name="keywords" content="{block name='head_seo_keywords'}{$page.meta.keywords}{/block}">
<meta name="robots" content="{$page.meta.robots}">
{if $page.page_name ="product"}
{assign var=img_social_share value=$product.cover.bySize.large_default.url}
<meta property="og:image" content={$img_social_share} />
{/if}
{if $page.canonical}
<link rel="canonical" href="{$page.canonical}">
{/if}
{/block}
{block name='head_hreflang'}
{assign "alternative_langs" $urls.alternative_langs|default:[]}
{foreach $alternative_langs as $code => $pageUrl}
<link rel="alternate" href="{$pageUrl}" hreflang="{$code}">
{/foreach}
{/block}
{block name='head_viewport'}
<meta name="viewport" content="width=device-width, initial-scale=1">
{/block}
{block name='head_icons'}
<link rel="icon" type="image/vnd.microsoft.icon" href="{$shop.favicon}?{$shop.favicon_update_time}">
<link rel="shortcut icon" type="image/x-icon" href="{$shop.favicon}?{$shop.favicon_update_time}">
{/block}
{if $page.page_name == 'index' && $djv_flags.template.opinions.trustivity}
<link href='//www.trustivity.es/css/style_widget_trustivity.css'
rel='stylesheet' type='text/css'>
{/if}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&display=swap" rel="stylesheet">
<!--link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous"-->
{block name='stylesheets'}
{include file="_partials/stylesheets.tpl" stylesheets=$stylesheets}
{/block}
{block name='javascript_head'}
<script>var djv_project = '{$djv_project}'; </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
{if $djv_flags.template.gtm.id}
<!-- 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','{$djv_flags.template.gtm.id}');</script>
<!-- End Google Tag Manager -->
{/if}
{include file="_partials/javascript.tpl" javascript=$javascript.head vars=$js_custom_vars}
{* TODO: Cargar solo si esta definido en variable de plantilla *}
{*include file='_partials/javascript-'|cat:$djv_project|cat:'.tpl' javascript=$javascript.head vars=$js_custom_vars*}
{/block}
{block name='hook_header'}
{$HOOK_HEADER nofilter}
{/block}
{block name='hook_extra'}{/block}
<meta name="facebook-domain-verification" content="fki799u2ilw1twnjx30giavgr5qnns" />
¡MUCHA SGRACIAS!