function gaCounter(){ 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); this.ids={ 'common': 'UA-9478516-24', 'local': 'UA-9478516-12' }; this.user_id = '14594' if(!this.ids['local'] || this.ids['local'].substring(0,2)=='{'+'{') this.ids['local']=this.ids['default']; var matches=document.location.host.match(/(\.?)([^\.]+)\.([a-z]+)$/);//(.)(exat).(ru) if(matches && matches[1]){ this.host=matches[0]; } this.initCounter('local'); this.initCounter('common'); } gaCounter.prototype.addOrganic = function() { } gaCounter.prototype.trackPageviews = function(event_source /*SearchResultContext*/, event_type /*view|click*/, banner_id /*hott.ru-egypt*/) { var url='/gaTrackPageview/'+event_source+'/'+event_type+'/id/'+banner_id+'/'; this.trackPageview('local', url); this.trackPageview('common', url); } gaCounter.prototype.trackPageview = function(name, url) { this.customVar(name, 3, 'user_id', '14594', 3); if(url==undefined) _gaq.push(['exat'+name+'._trackPageview']); else _gaq.push(['exat'+name+'._trackPageview',url]); } gaCounter.prototype.trackEvents= function(category, action, id){ this.trackEvent('local', category, action, id); this.trackEvent('common', category, action, id); } gaCounter.prototype.trackEvent= function(countertype, category, action, id){ _gaq.push(['exat'+countertype+'._trackEvent', category, action, id]); } gaCounter.prototype.customVars= function(index, name, value, opt_scope){ this.customVar('local', index, name, value, opt_scope); this.customVar('common', index, name, value, opt_scope); } gaCounter.prototype.customVar= function(countertype, index, name, value, opt_scope){ _gaq.push(['exat'+countertype+'._setCustomVar', index, name, value, opt_scope]); } gaCounter.prototype.initCounter = function(name,url) { var id=this.ids[name]; _gaq.push(['exat'+name+'._setAccount', id]); this.addOrganic(name); if(this.host){ _gaq.push(['exat'+name+'._setDomainName', this.host]); } this.trackPageview(name, url); } var _gaq = _gaq || []; var gaCounters= gaCounters || new gaCounter();