ホーム » 2018 » 12月 » 07

日別アーカイブ: 2018/12/07

2018年12月
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,967 アクセス



Google アナリティクスの設定

analytics.js と gtag.js .


index.html など,エディタで書いた html .
Google アナリティクスに関して,次の 2 つの書き方が混在していた.

    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-TRACKING_ID', 'auto');
        ga('send', 'pageview');
    </script>

    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-TRACKING_ID"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'UA-TRACING_ID');
    </script>

検索すると,上の analytics.js は古い形式みたい.

 Google アナリティクスの設定
 最新!?Google Analyticsの「Global Site Tag」(gtag.js)

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.