Commit 4724305d by Simone

nuova features Google tag manager

parent 29731cbc
...@@ -136,6 +136,11 @@ function laniakea_tab_options() ...@@ -136,6 +136,11 @@ function laniakea_tab_options()
'id' => 'iubenda', 'id' => 'iubenda',
'icon' => 'cookie', 'icon' => 'cookie',
'label' => 'Iubenda' 'label' => 'Iubenda'
],
[
'id' => 'Google',
'icon' => 'google fa-brands',
'label' => 'Google'
] ]
]; ];
} }
<div class="field-group">
<h3>ID contenitore</h3>
<?php laniakea_input('google_tag_manager', 'text'); ?>
</div>
\ No newline at end of file
...@@ -26,6 +26,39 @@ function laniakea_compress_css($css = '') ...@@ -26,6 +26,39 @@ function laniakea_compress_css($css = '')
return $css; return $css;
} }
function laniakea_gtm($position)
{
if (empty($position)) return;
$id = laniakea_option('google_tag_manager');
if (!empty($id)) {
if ($position == 'head') : ?>
<!-- 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', '<?php echo $id ?>');
</script>
<!-- End Google Tag Manager -->
<?php elseif ($position == 'body') : ?>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<?php echo $id ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<?php endif;
}
}
function laniakea_get_googleapi_font() function laniakea_get_googleapi_font()
{ {
......
...@@ -123,11 +123,11 @@ function laniakea_register_required_plugins() ...@@ -123,11 +123,11 @@ function laniakea_register_required_plugins()
'name' => 'CookieYes', 'name' => 'CookieYes',
'slug' => 'cookie-law-info', 'slug' => 'cookie-law-info',
), ),
array( /* array(
'name' => 'GTM4WP', 'name' => 'GTM4WP',
'slug' => 'duracelltomi-google-tag-manager', 'slug' => 'duracelltomi-google-tag-manager',
'required' => true 'required' => true
), ), */
array( array(
'name' => 'Meta pixel for WordPress', 'name' => 'Meta pixel for WordPress',
'slug' => 'official-facebook-pixel', 'slug' => 'official-facebook-pixel',
......
...@@ -18,6 +18,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header; ...@@ -18,6 +18,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header;
<link rel="pingback" href="<?php esc_url(bloginfo('pingback_url')); ?>" /> <link rel="pingback" href="<?php esc_url(bloginfo('pingback_url')); ?>" />
<?php laniakea_get_googleapi_font(); ?> <?php laniakea_get_googleapi_font(); ?>
<?php laniakea_gtm('head'); ?>
<?php wp_head(); ?> <?php wp_head(); ?>
<?php <?php
...@@ -30,6 +31,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header; ...@@ -30,6 +31,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header;
<body <?php body_class(); ?>> <body <?php body_class(); ?>>
<?php wp_body_open(); ?> <?php wp_body_open(); ?>
<?php laniakea_gtm('body'); ?>
<div id="wrapper"> <div id="wrapper">
<header id="main-header" <?php if (!empty($show_header_inverted)) echo 'class="inverted"' ?>> <header id="main-header" <?php if (!empty($show_header_inverted)) echo 'class="inverted"' ?>>
<?php if (laniakea_option('show_preheader') == 1) get_template_part('templates/pre', 'header'); ?> <?php if (laniakea_option('show_preheader') == 1) get_template_part('templates/pre', 'header'); ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment