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