Commit 4724305d by Simone

nuova features Google tag manager

parent 29731cbc
......@@ -136,6 +136,11 @@ function laniakea_tab_options()
'id' => 'iubenda',
'icon' => 'cookie',
'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 = '')
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()
{
......@@ -249,4 +282,4 @@ function laniakea_bakery_btn_colors()
'default' => '#ffffff'
]
];
}
\ No newline at end of file
}
......@@ -123,11 +123,11 @@ function laniakea_register_required_plugins()
'name' => 'CookieYes',
'slug' => 'cookie-law-info',
),
array(
/* array(
'name' => 'GTM4WP',
'slug' => 'duracelltomi-google-tag-manager',
'required' => true
),
), */
array(
'name' => 'Meta pixel for WordPress',
'slug' => 'official-facebook-pixel',
......
......@@ -18,6 +18,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header;
<link rel="pingback" href="<?php esc_url(bloginfo('pingback_url')); ?>" />
<?php laniakea_get_googleapi_font(); ?>
<?php laniakea_gtm('head'); ?>
<?php wp_head(); ?>
<?php
......@@ -30,6 +31,7 @@ $show_header_inverted = $slider || $laniakea_transparent_header;
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<?php laniakea_gtm('body'); ?>
<div id="wrapper">
<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'); ?>
......
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