最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Google Analytics - add script to functions.php

programmeradmin8浏览0评论

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=";></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-00000000-1');
</script>
<?php
}
发布评论

评论列表(0)

  1. 暂无评论