サマリ | Googleアナリティクスのコードを追加 |
---|---|
リビジョン | 1.0 |
対応バージョン | All (未確認) |
投稿者 | NoName |
投稿日 | 2016-01-18 (月) 13:43:11 |
Googleアナリティクスのコードを追加するだけのプラグイン。
#google_analyticで追加。表示無し。
body>~</body>の間に挿入されるため非推奨動作。*1
MenuBarやスキン等一度のみの実行を推奨。
<?php define(ANALYTICS_ID, 'UA-0000000-0'); // 設定したいアナリティクスID function plugin_google_analytics_init() { $_id = ANALYTICS_ID; return <<<_TAG <!- GoogleAnalyticsStart --> <script type="text/javascript"><!-- (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','//www.google-analytics.com/analytics.js','ga'); ga('create', '{$_id}', 'auto'); ga('send', 'pageview'); // --></script> <!- GoogleAnalyticsEnd --> _TAG; } ?>