google_analytics.inc.php

サマリGoogleアナリティクスのコードを追加
リビジョン1.0
対応バージョンAll (未確認)
投稿者NoName
投稿日2016-01-18 (月) 13:43:11

Googleアナリティクスのコードを追加するだけのプラグイン。

#google_analyticで追加。表示無し。

body>~</body>の間に挿入されるため非推奨動作。*1
MenuBarやスキン等一度のみの実行を推奨。

google_analytics.inc.php

<?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;
}
?>

バグなど



*1 昔は推奨だったが現在は非推奨。一応動くらしい

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-11-21 (火) 23:42:13
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 0.767 sec.

SourceForge