-3
我的脚本下面的代码,但由于某些原因,它不工作,请帮助谢谢无法获取地理位置脚本工作
<script>
$.getScript('http://www.geoplugin.net/javascript.gp', function() {
$location = geoplugin_countryCode();
$location2 = geoplugin_continentCode();
if($location == "CA" || $location == "US" || $location2 == "EU" || $location2 == "DE" || $location2 == "FR" || $location2 == "GB") {
alert($location);
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9240923-27']);
_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);
})();
} else {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9240923-27']);
_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>
你是什么意思,它不起作用?发生了什么,你期望会发生什么? – 2012-07-12 08:31:06
它不显示在谷歌分析 – Chriswede 2012-07-12 08:35:59
我不知道我明白你想在这里完成。您正在if和else子句中加载分析?为什么不在if语句之后呢呢?为什么你要在getScript的成功回调中加载Google Analytics? – 2012-07-12 08:40:31