Strict Standards: Non-static method Protector::getInstance() should not be called statically in /home/suehirogari/suehirogari.com/xoops_trust_path/modules/protector/include/precheck_functions.php on line 12

Strict Standards: Non-static method XCube_Root::getSingleton() should not be called statically in /home/suehirogari/suehirogari.com/public_html/include/common.php on line 18

Deprecated: Non-static method XCube_Root::getSingleton() should not be called statically, assuming $this from incompatible context in /home/suehirogari/suehirogari.com/public_html/modules/user/preload/Primary/Primary.class.php on line 13
jQueryMobile内でGoogle Analyticsでアクセス解析する方法 | 社内SEのウェブ制作

2012.09.13xoopsズープス

jQueryMobile内でGoogle Analyticsでアクセス解析する方法

 jQueryMobielでGoogle Analyticswoでアクセス解析するにはソースの追加箇所に注意が必要です。

jQueryMobileサイトは、ページ内のページ移動をjQueryで行っており、外枠のソースは一切変わっていないようです。そのため、必ず毎回読まれるソースの箇所に、Google Analyticsのソースを埋め込む必要があります。

Google Analyticsを埋め込む箇所

 

<script type="text/javascript" src="<{$xoops_imageurl}>js/jquery.js"></script> <!-- ここに埋め込む  --> <script type="text/javascript" src="<{$xoops_imageurl}>js/jquery.cycle.all.min.js"></script>

 

埋め込むソースの内容

/*
 * Google Analytics 設定
 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-****-*']);

// ページトラッキング
$(document).bind('mobileinit', function(){
	$(':jqmData(role="page")').live('pageshow', function (event, ui) {
		_gaq.push(['_trackPageview', $.mobile.activePage.jqmData('url')]);
	});
}

// Google Analytics 読み込み
$(document).ready(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);
});


このカテゴリの人気記事



  • コメント (0)
  • トラックバック (0)
  • 閲覧 (18832)

トラックバック

トラックバックpingアドレス http://www.suehirogari.com/modules/blog/tb.php/589

コメントの投稿

コメント投稿に関するルール : コメントは全て承認が必要

キーワードでサイト内を検索
人気のエントリ