.htaccess - Mod_pagespeed do not work for make_google_analytics_async -


this code in .htaccess file ... , sure mode_pagespeed works.

<ifmodule pagespeed_module> modpagespeed on modpagespeedenablefilters make_google_analytics_async . . . </ifmodule> 

and in html add java script code (i got here)

<html> <head>  <script type='text/javascript'>   var gajshost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");   glue_script   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> <script type="text/javascript">   try {     var pagetracker = _modpagespeed_getrewritetracker("ua-63697801-1");     pagetracker._trackpageview();   } catch(err) {} </script> </head> <body>  </body> </html> 

what's wrong? not work filter insert_ga works not optimized.

you need replace glue_script function. docs

where glue_script javascript defines _modpagespeed_getrewritetracker function return object maps methods of synchronous api asynchronous api.

if follow example below link provided, can see full implementation.

var gajshost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); var _gaq = _gaq || []; (function () {     function functionname(fn) {         var name = /\w*function\s+([\w\$]+)\(/.exec(fn);         if (!name)             return 'no name';         return name[1];     }      var namespace = '_gat';     var existinggat = window[namespace];     if (existinggat && typeof existinggat['_gettracker'] == 'function') {         return;     }      var gaqaccounts = [];      function setaccount(acct, prefix) {         if (gaqaccounts[prefix] != acct) {             gaqaccounts[prefix] = acct;             _gaq.push([prefix + '_setaccount', acct]);         }     }      window['_modpagespeed_getrewritetracker'] = function (tracker_acct,                                                           tracker_name) {         var prefix = tracker_name ? tracker_name + '.' : '';          function defertrackerfunc(fn) {             return function () {                 setaccount(tracker_acct, prefix);                 var pushargs = [fn];                 [].push.apply(pushargs, arguments);                 _gaq.push(pushargs);             };         }          var pagetrackermethodnames = [             '_trackpageview',             '_trackevent',             '_tracktrans',             '_addignoredorganic',             '_addignoredref',             '_additem',             '_addorganic',             '_addtrans',             '_clearignoredorganic',             '_clearignoredref',             '_clearorganic',             '_clearxkey',             '_clearxvalue',             '_cookiepathcopy',             '_deletecustomvar',             '_link',             '_linkbypost',             '_sendxevent',             '_setallowanchor',             '_setallowhash',             '_setallowlinker',             '_setautotrackoutbound',             '_setcampcidkey',             '_setcampcontentkey',             '_setcampidkey',             '_setcampmediumkey',             '_setcampnokey',             '_setcampnamekey',             '_setcampsourcekey',             '_setcamptermkey',             '_setcampaigncookietimeout',             '_setcampaigntrack',             '_setclientinfo',             '_setcookiepath',             '_setcookiepersistence',             '_setcookietimeout',             '_setcustomvar',             '_setdetectflash',             '_setdetecttitle',             '_setdomainname',             '_sethrefexaminelimit',             '_setlocalgifpath',             '_setlocalremoteservermode',             '_setlocalservermode',             '_setmaxcustomvariables',             '_setnamespace',             '_setreferreroverride',             '_setremoteservermode',             '_setsamplerate',             '_setsessioncookietimeout',             '_setsessiontimeout',             '_settrackoutboundsubdomains',             '_settrans',             '_settransactiondelim',             '_setvar',             '_setvisitorcookietimeout',             '_setxkey',             '_setxvalue'         ];         var pagetracker = {             _initdata: function () {             },         };         (var = pagetrackermethodnames.length; i--;) {             var n = pagetrackermethodnames[i];             pagetracker[n] = defertrackerfunc(prefix + n);         }         return pagetracker;     };      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); })(); try {     var pagetracker = _modpagespeed_getrewritetracker("ua-xxxx-9");     pagetracker._trackpageview(); } catch (err) { } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -