Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Filter "make_google_analytics_async" turns benign call to deprecated method into a functional error #441

@GoogleCodeExporter

Description

@GoogleCodeExporter
Problem: Javascript error "Uncaught TypeError: Object #<Object> has no method 
'_initData' "

From what I read, the following call: "pageTracker._initData();" is a 
deprecated call that is harmless. However, when the filter is enabled, this 
causes the above javascript error.  It's easy enough for someone to correct 
this by removing the deprecated line of code but thought it might be worth 
reporting. It would be nice if the filter just detected and fixed this case.

What steps will reproduce the problem?
1. Enable filter: make_google_analytics_async

What is the expected output? What do you see instead?

Here is the before script:
<!--Google start Analytics-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : 
"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + 
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker('UA-XXXXXX-10'); 
pageTracker._initData(); 
pageTracker._trackPageview(); 
</script>
<!--Google end Analytics-->

After filter:
<!--Google start Analytics-->
<script orig_type="text/javascript" type="text/psajs" orig_index="6">var 
gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");v
ar _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){va
r 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','_addIgnore
dOrganic','_addIgnoredRef','_addItem','_addOrganic','_addTrans','_clearIgnoredOr
ganic','_clearIgnoredRef','_clearOrganic','_clearXKey','_clearXValue','_cookiePa
thCopy','_deleteCustomVar','_link','_linkByPost','_sendXEvent','_setAllowAnchor'
,'_setAllowHash','_setAllowLinker','_setAutoTrackOutbound','_setCampCIdKey','_se
tCampContentKey','_setCampIdKey','_setCampMediumKey','_setCampNOKey','_setCampNa
meKey','_setCampSourceKey','_setCampTermKey','_setCampaignCookieTimeout','_setCa
mpaignTrack','_setClientInfo','_setCookiePath','_setCookiePersistence','_setCook
ieTimeout','_setCustomVar','_setDetectFlash','_setDetectTitle','_setDomainName',
'_setHrefExamineLimit','_setLocalGifPath','_setLocalRemoteServerMode','_setLocal
ServerMode','_setMaxCustomVariables','_setNamespace','_setReferrerOverride','_se
tRemoteServerMode','_setSampleRate','_setSessionCookieTimeout','_setSessionTimeo
ut','_setTrackOutboundSubdomains','_setTrans','_setTransactionDelim','_setVar','
_setVisitorCookieTimeout','_setXKey','_setXValue'];var 
pageTracker={initData:function(){},};for(var 
i=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.s
rc=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-an
alytics.com/ga.js';var 
s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})(
);</script>
<script orig_type="text/javascript" type="text/psajs" orig_index="7">var 
pageTracker=_modpagespeed_getRewriteTracker('UA-2391884-10');pageTracker._initDa
ta();pageTracker._trackPageview();</script>
<!--Google end Analytics-->

What version of the product are you using (please check X-Mod-Pagespeed
header)? 1583

On what operating system? Ubuntu 10.04

Which version of Apache? 2.2

Which MPM? Event

Original issue reported on code.google.com by hayes...@gmail.com on 22 May 2012 at 7:24

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions