10 stycznia, 2021

WordPress – dodawanie kodu google analitycs w functions.php



function hook_codebook_gtag() {

?>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-XXXXXXXXX-X');
</script>

<?php
}

add_action('wp_head', 'hook_codebook_gtag');