WordPress Development Asked by Szachmat on November 19, 2020
I want to connect google analytics to my site. I don’t want to do it through the MonsterInsights plug-in. I added this script to functions.php. Will it work?
<?php
/**
* Add functions files
*
* @package Virtue Theme
*/
/**
* Language setup
*/
function virtue_lang_setup() {
load_theme_textdomain( 'virtue', get_template_directory() . '/languages' );
}
add_action('wp_head', 'my_analytics', 20);
function my_analytics() {
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-00000000-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-00000000-1');
</script>
<?php
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP