「関数リファレンス/BcBaser googleAnalytics」の版間の差分
提供: baserCMS公式ガイド
Goichi Maniwa (トーク | 投稿記録) (ページの作成:「## 説明 管理画面で登録された「GoogleAnalyticsウェブプロパティID」を利用し、GoogleAnalytics用のトラッキングコードを出力します...」) |
Tomohiro Abe (トーク | 投稿記録) |
||
(3人の利用者による、間の4版が非表示) | |||
行9: | 行9: | ||
## パラメータ | ## パラメータ | ||
− | $data | + | (array)$data |
− | : | + | : 読み込むテンプレートに引き継ぐパラメータ |
− | :- 初期値:array() | + | : - 初期値:array() |
− | $options | + | (array)$options |
− | : | + | : オプションを指定する |
:- 初期値:array() | :- 初期値:array() | ||
行64: | 行64: | ||
##類似の関数 | ##類似の関数 | ||
− | [ | + | [googleMaps](/関数リファレンス/googleMaps) |
− | [[Category: | + | [[Category:関数リファレンス]] |
2016年3月29日 (火) 16:27時点における最新版
目次
説明
管理画面で登録された「GoogleAnalyticsウェブプロパティID」を利用し、GoogleAnalytics用のトラッキングコードを出力します。事前にGoogleAnalyticsに登録し、システム管理で、「UA-」から始まるIDを登録しておく必要があります。
使い方
$this->BcBaser-> googleAnalytics( array $data = array(), array $options = array() );
パラメータ
- (array)$data
- 読み込むテンプレートに引き継ぐパラメータ
- - 初期値:array()
- (array)$options
- オプションを指定する
- - 初期値:array()
戻り値
- なし
用例
基本
コード
<?php $this->BcBaser->googleAnalytics(); ?>
出力
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>