updated to new google analytics snippet and syntax

This commit is contained in:
Sacha Greif 2013-10-31 09:55:44 +09:00
parent ad363ea964
commit 60f3876f9e

View file

@ -60,14 +60,12 @@ analyticsInit = function() {
// Google Analytics // Google Analytics
if (googleAnalyticsId = getSetting("googleAnalyticsId")){ if (googleAnalyticsId = getSetting("googleAnalyticsId")){
window._gaq = window._gaq || []; (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
window._gaq.push(['_setAccount', googleAnalyticsId]); (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');
(function() { window.ga('create', googleAnalyticsId);
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);
})();
} }
@ -76,8 +74,10 @@ analyticsInit = function() {
analyticsRequest = function() { analyticsRequest = function() {
// Google Analytics // Google Analytics
if (googleAnalyticsId = getSetting("googleAnalyticsId") && window._gaq){ if (typeof window.ga !== 'undefined'){
window._gaq.push(['_trackPageview', window.location.pathname]); ga('send', 'pageview', {
'page': window.location.pathname,
});
} }
// Mixpanel // Mixpanel