<?php
/*
Plugin Name: Google Analytics
Plugin URI: https://wujie.me
Description: Google 数据统计服务
Author: 吴杰
Version: 2021.04.09
Author URI: https://wujie.me
*/

function google_analytics_code()
{
echo <<<EOF
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-14WREEPT2T"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-14WREEPT2T');
</script>
EOF;
}
add_action('wp_footer', 'google_analytics_code');