Universal-Federated-Analytics-Min.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. .ooooo. ooo. .oo. .ooooo. oooo d8b
  3. d88" `88b `888P"Y88b d88" `88b `888""8P
  4. 888888888 88888 888 888 888 888 888
  5. 888 88888 888 888 888 888 888
  6. `"88888" o888o o888o `Y8bod8P" d888b
  7. ***********************************************************************************************************
  8. Copyright 2015 by E-Nor Inc.
  9. Universal Federated Analytics: Google Analytics Government Wide Site Usage Measurement.
  10. 05/19/2015 Version: 2.01
  11. ***********************************************************************************************************/
  12. var oCONFIG={GWT_UAID:['UA-33523145-1'],FORCE_SSL:true,ANONYMIZE_IP:true,AGENCY:'',SUB_AGENCY:'',VERSION:'20150519 v2.01 - Universal Analytics',USE_MAIN_CUSTOM_DIMENSIONS:true,MAIN_AGENCY_CUSTOM_DIMENSION_SLOT:'dimension1',MAIN_SUBAGENCY_CUSTOM_DIMENSION_SLOT:'dimension2',MAIN_CODEVERSION_CUSTOM_DIMENSION_SLOT:'dimension3',USE_PARALLEL_CUSTOM_DIMENSIONS:false,PARALLEL_AGENCY_CUSTOM_DIMENSION_SLOT:'dimension1',PARALLEL_SUBAGENCY_CUSTOM_DIMENSION_SLOT:'dimension2',PARALLEL_CODEVERSION_CUSTOM_DIMENSION_SLOT:'dimension3',COOKIE_DOMAIN:location.hostname.replace('www.','').toLowerCase(),COOKIE_TIMEOUT:60*60*24*2*365,SEARCH_PARAMS:'q|querytext|nasaInclude|k|qt',YOUTUBE:false,AUTOTRACKER:true,EXTS:'doc|docx|xls|xlsx|xlsm|ppt|pptx|exe|zip|pdf|js|txt|csv|dxf|dwgd|rfa|rvt|dwfx|dwg|wmv|jpg|msi|7z|gz|tgz|wma|mov|avi|mp3|mp4|csv|mobi|epub|swf|rar',SUBDOMAIN_BASED:true,DOUNBLECLICK_LINK:false,ENHANCED_LINK:false,OPTOUT_PAGE:false,PUA_NAME:'GSA_ENOR'};function _onEveryPage(){_updateConfig();_defineCookieDomain();_defineAgencyCDsValues();}
  13. _onEveryPage();function _defineCookieDomain()
  14. {var domainPattern=/(([^.\/]+\.[^.\/]{2,3}\.[^.\/]{2})|(([^.\/]+\.)[^.\/]{2,4}))(\/.*)?$/;if(domainPattern.test(oCONFIG.SUBDOMAIN_BASED.toString()))
  15. {oCONFIG.COOKIE_DOMAIN=oCONFIG.SUBDOMAIN_BASED.toLowerCase().replace('www.','');oCONFIG.SUBDOMAIN_BASED=true;}
  16. else
  17. {if(oCONFIG.SUBDOMAIN_BASED.toString()=='false')
  18. {oCONFIG.COOKIE_DOMAIN=document.location.hostname.match(/(([^.\/]+\.[^.\/]{2,3}\.[^.\/]{2})|(([^.\/]+\.)[^.\/]{2,4}))(\/.*)?$/)[1];oCONFIG.SUBDOMAIN_BASED=true;}
  19. else if(oCONFIG.SUBDOMAIN_BASED.toString()=='auto'||oCONFIG.SUBDOMAIN_BASED=='true')
  20. {oCONFIG.COOKIE_DOMAIN=location.hostname.toLowerCase().replace('www.','');oCONFIG.SUBDOMAIN_BASED=false;}
  21. else
  22. {oCONFIG.COOKIE_DOMAIN=location.hostname.toLowerCase().replace('www.','');oCONFIG.SUBDOMAIN_BASED=false;}}}
  23. function _defineAgencyCDsValues()
  24. {oCONFIG.AGENCY=oCONFIG.AGENCY||'unspecified:'+oCONFIG.COOKIE_DOMAIN;oCONFIG.SUB_AGENCY=oCONFIG.SUB_AGENCY||(''+oCONFIG.COOKIE_DOMAIN);oCONFIG.SUB_AGENCY=oCONFIG.AGENCY+' - '+oCONFIG.SUB_AGENCY;}
  25. function _cleanBooleanParam(_paramValue){switch(_paramValue.toString().toLowerCase()){case'true':case'on':case'yes':case'1':return'true';case'false':case'off':case'no':case'0':return'false';default:return _paramValue;}}
  26. function _isValidUANum(_UANumber){_UANumber=_UANumber.toLowerCase();var _regEx=/^ua\-([0-9]+)\-[0-9]+$/;var match=_UANumber.match(_regEx);return(match!=null&&match.length>0);}
  27. function _cleanDimensionValue(_paramValue){try{pattern=/^dimension([1-9]|[1-9][0-9]|1([0-9][0-9])|200)$/;if(pattern.test(_paramValue))
  28. return _paramValue;var _tmpValue='dimension'+_paramValue.match(/\d+$/g)[0];if(pattern.test(_tmpValue))
  29. return _tmpValue;return'';}catch(err){}}
  30. function _updateConfig(){var _JSElement=document.getElementById('_fed_an_ua_tag').getAttribute('src');_JSElement=_JSElement.replace(/\?/g,'&');var _paramList=_JSElement.split('&');for(var i=1;i<_paramList.length;i++){_keyValuePair=_paramList[i].toLowerCase();_key=_keyValuePair.split('=')[0];_value=_keyValuePair.split('=')[1];switch(_key){case'pua':var _UAList=_value.split(',');for(var j=0;j<_UAList.length;j++)
  31. if(_isValidUANum(_UAList[j]))
  32. oCONFIG.GWT_UAID.push(_UAList[j].toUpperCase());break;case'agency':oCONFIG.AGENCY=_value.toUpperCase();break;case'subagency':oCONFIG.SUB_AGENCY=_value.toUpperCase();break;case'maincd':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  33. oCONFIG.USE_MAIN_CUSTOM_DIMENSIONS=_value;break;case'fedagencydim':_value=_cleanDimensionValue(_value);if(''!=_value)
  34. oCONFIG.MAIN_AGENCY_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'fedsubagencydim':_value=_cleanDimensionValue(_value);if(''!=_value)
  35. oCONFIG.MAIN_SUBAGENCY_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'fedversiondim':_value=_cleanDimensionValue(_value);if(''!=_value)
  36. oCONFIG.MAIN_CODEVERSION_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'parallelcd':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  37. oCONFIG.USE_PARALLEL_CUSTOM_DIMENSIONS=_value;break;case'palagencydim':_value=_cleanDimensionValue(_value);if(''!=_value)
  38. oCONFIG.PARALLEL_AGENCY_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'palsubagencydim':_value=_cleanDimensionValue(_value);if(''!=_value)
  39. oCONFIG.PARALLEL_SUBAGENCY_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'palversiondim':_value=_cleanDimensionValue(_value);if(''!=_value)
  40. oCONFIG.PARALLEL_CODEVERSION_CUSTOM_DIMENSION_SLOT=_value.toLowerCase();break;case'cto':oCONFIG.COOKIE_TIMEOUT=parseInt(_value)*2628000;break;case'sp':oCONFIG.SEARCH_PARAMS+='|'+_value.replace(/,/g,'|');break;case'exts':oCONFIG.EXTS+='|'+_value.replace(/,/g,'|');break;case'yt':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  41. oCONFIG.YOUTUBE=_value;break;case'autotracker':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  42. oCONFIG.AUTOTRACKER=_value;break;case'sdor':oCONFIG.SUBDOMAIN_BASED=_cleanBooleanParam(_value);break;case'dclink':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  43. oCONFIG.DOUNBLECLICK_LINK=_value;break;case'enhlink':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  44. oCONFIG.ENHANCED_LINK=_value;break;case'optout':_value=_cleanBooleanParam(_value);if('true'==_value||'false'==_value)
  45. oCONFIG.OPTOUT_PAGE=_value;break;default:break;}}}
  46. function _sendCustomDimensions(_slotNums,_val)
  47. {if(_slotNums.length>0&&_val!=''&&_val!=undefined)
  48. {if(tObjectCheck!=window['GoogleAnalyticsObject'])
  49. {createTracker(false);}
  50. for(var i=0;i<oCONFIG.GWT_UAID.length;i++)
  51. {if(_slotNums[i]!='dimension0')
  52. {try
  53. {window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+i+'.set',_slotNums[i],_val);}
  54. catch(err)
  55. {}}}}}
  56. function _sendCustomMetrics(_slotNums,_val)
  57. {if(_slotNums.length>0&&_val!=''&&_val!=undefined)
  58. {if(tObjectCheck!=window['GoogleAnalyticsObject'])
  59. {createTracker(false);}
  60. for(var i=0;i<oCONFIG.GWT_UAID.length;i++)
  61. {if(_slotNums[i]!='metric0')
  62. {try
  63. {window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+i+'.set',_slotNums[i],_val);}
  64. catch(err)
  65. {}}}}}
  66. function _sendEvent(_cat,_act,_lbl,_val,_nonInteraction){if(_cat!=''&&_cat!=undefined&&_act!=''&&_act!=undefined)
  67. {if(tObjectCheck!=window['GoogleAnalyticsObject'])
  68. {createTracker(false);}
  69. for(var i=0;i<oCONFIG.GWT_UAID.length;i++)
  70. {try
  71. {window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+i+'.send','event',_cat,_act,((_lbl!=undefined)?_lbl:''),((_val!=''||!isNaN(_val)||_val!=undefined)?parseInt(_val):0),{'nonInteraction':_nonInteraction});}
  72. catch(err)
  73. {}}}}
  74. function _sendPageview(_virtualPath,_virtualTitle)
  75. {if(_virtualPath!=''&&_virtualPath!=undefined)
  76. {if(tObjectCheck!=window['GoogleAnalyticsObject'])
  77. {createTracker(false);}
  78. for(var i=0;i<oCONFIG.GWT_UAID.length;i++)
  79. {try
  80. {window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+i+'.send','pageview',{'page':_virtualPath,'title':((_virtualTitle!=''||_virtualTitle!=undefined)?_virtualTitle:document.title)});}
  81. catch(err)
  82. {}}}}
  83. function gas(_command,_hitType,_param1,_param2,_param3,_param4,_param5)
  84. {if(_command!=undefined&&_command!=''&&_hitType!=undefined&&_hitType!=''&&_param1!=undefined&&_param1!='')
  85. {if(_hitType.toLowerCase()=='pageview')
  86. {try
  87. {_sendPageview(_param1,((_param2!=''||_param2!=undefined)?_param2:document.title));}
  88. catch(err)
  89. {}}
  90. else if(_hitType.toLowerCase()=='event'&&_param2!=undefined&&_param2!='')
  91. {try
  92. {var _nonInteraction='false';if(_param5==undefined)
  93. {_param5=_nonInteraction;}
  94. else
  95. {_nonInteraction=_cleanBooleanParam(_param5);}
  96. _sendEvent(_param1,_param2,((_param3!=undefined)?_param3:''),((_param4!=''||!isNaN(_param4)||_param4!=undefined)?parseInt(_param4):0),((_nonInteraction=='true')?1:0));}
  97. catch(err)
  98. {}}
  99. else if(_hitType.toLowerCase().indexOf('dimension')!=-1)
  100. {try
  101. {var cdsTmpArr=_hitType.toLowerCase().split(',');var cdsArr=[];dimsPattern=/^dimension([1-9]|[1-9][0-9]|1([0-9][0-9])|200)$/;for(var ix=0;ix<cdsTmpArr.length;ix++)
  102. {if(dimsPattern.test(cdsTmpArr[ix]))
  103. {cdsArr.push(cdsTmpArr[ix]);}
  104. else
  105. {var tmpDim='dimension'+cdsTmpArr[ix].match(/\d+$/g)[0];if(dimsPattern.test(tmpDim)||tmpDim=='dimension0')
  106. {cdsArr.push(tmpDim);}}}
  107. if(cdsArr.length>0)
  108. {_sendCustomDimensions(cdsArr,((_param1!=undefined)?_param1:''));}}
  109. catch(err)
  110. {}}
  111. else if(_hitType.toLowerCase().indexOf('metric')!=-1)
  112. {try
  113. {var mtrcsTmpArr=_hitType.toLowerCase().split(',');var mtrcsArr=[];mtrcsPattern=/^metric([1-9]|[1-9][0-9]|1([0-9][0-9])|200)$/;for(var ixx=0;ixx<mtrcsTmpArr.length;ixx++)
  114. {if(mtrcsPattern.test(mtrcsTmpArr[ixx]))
  115. {mtrcsArr.push(mtrcsTmpArr[ixx]);}
  116. else
  117. {var tmpMtrcs='metric'+mtrcsTmpArr[ixx].match(/\d+$/g)[0];if(mtrcsPattern.test(tmpMtrcs)||tmpMtrcs=='metric0')
  118. {mtrcsArr.push(tmpMtrcs);}}}
  119. if(mtrcsArr.length>0)
  120. {_sendCustomMetrics(mtrcsArr,((_param1!=''||_param1!=undefined||!isNaN(_param1))?parseFloat(_param1):1));}}
  121. catch(err)
  122. {}}}}
  123. function _URIHandler(pageName){var re=new RegExp('([?&])('+oCONFIG.SEARCH_PARAMS+')(=[^&]*)','i');if(re.test(pageName)){pageName=pageName.replace(re,'$1query$3');}
  124. return pageName;}
  125. var tObjectCheck;if(typeof window['GoogleAnalyticsObject']=='undefined')
  126. {(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');tObjectCheck=window['GoogleAnalyticsObject'];}
  127. else
  128. {tObjectCheck=window['GoogleAnalyticsObject'];}
  129. createTracker(true);function createTracker(sendPv)
  130. {for(var dpv=0;dpv<oCONFIG.GWT_UAID.length;dpv++)
  131. {var _adjPageUri=_URIHandler(document.location.pathname+document.location.search+document.location.hash);if(oCONFIG.OPTOUT_PAGE)
  132. {window['ga-disable-'+oCONFIG.GWT_UAID[dpv]]=true;};window[window['GoogleAnalyticsObject']]('create',oCONFIG.GWT_UAID[dpv],oCONFIG.COOKIE_DOMAIN,{'name':oCONFIG.PUA_NAME+dpv,'allowLinker':true,'cookieExpires':parseInt(oCONFIG.COOKIE_TIMEOUT)});if(oCONFIG.ANONYMIZE_IP){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set','anonymizeIp',oCONFIG.ANONYMIZE_IP);}
  133. if(oCONFIG.DOUNBLECLICK_LINK){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.require','displayfeatures');}
  134. if(oCONFIG.ENHANCED_LINK){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.require','linkid','linkid.js');}
  135. if(oCONFIG.FORCE_SSL){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set','forceSSL',true);}
  136. if(oCONFIG.USE_MAIN_CUSTOM_DIMENSIONS&&dpv==0){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.MAIN_AGENCY_CUSTOM_DIMENSION_SLOT,oCONFIG.AGENCY);window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.MAIN_SUBAGENCY_CUSTOM_DIMENSION_SLOT,oCONFIG.SUB_AGENCY);window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.MAIN_CODEVERSION_CUSTOM_DIMENSION_SLOT,oCONFIG.VERSION);}
  137. if(oCONFIG.USE_PARALLEL_CUSTOM_DIMENSIONS&&dpv>0){window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.PARALLEL_AGENCY_CUSTOM_DIMENSION_SLOT,oCONFIG.AGENCY);window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.PARALLEL_SUBAGENCY_CUSTOM_DIMENSION_SLOT,oCONFIG.SUB_AGENCY);window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.set',oCONFIG.PARALLEL_CODEVERSION_CUSTOM_DIMENSION_SLOT,oCONFIG.VERSION);}
  138. if(document.title.search(/404|not found/i)!==-1)
  139. {var vpv404='/vpv404/'+_adjPageUri;_adjPageUri=vpv404.replace(/\/\//g,'/')+'/'+document.referrer;}
  140. if(sendPv)
  141. {window[window['GoogleAnalyticsObject']](oCONFIG.PUA_NAME+dpv+'.send','pageview',_adjPageUri);}}}
  142. function _initAutoTracker()
  143. {var mainDomain=oCONFIG.COOKIE_DOMAIN;var extDoc=oCONFIG.EXTS.split("|");var arr=document.getElementsByTagName("a");for(i=0;i<arr.length;i++)
  144. {var flag=0;var flagExt=0;var doname="";var mailPattern=/^mailto\:[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;var urlPattern=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;var telPattern=/^tel\:(.*)([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;if(mailPattern.test(arr[i].href)||urlPattern.test(arr[i].href)||telPattern.test(arr[i].href))
  145. {try
  146. {if(urlPattern.test(arr[i].href))
  147. {doname=arr[i].hostname.toLowerCase().replace("www.","");}
  148. else if(mailPattern.test(arr[i].href))
  149. {doname=arr[i].href.split('@')[1];}
  150. else if(telPattern.test(arr[i].href))
  151. {doname=arr[i].href;doname=doname.toLowerCase();}}
  152. catch(err)
  153. {continue;}}
  154. else
  155. {continue;}
  156. var condition=false;if(oCONFIG.SUBDOMAIN_BASED)
  157. {condition=(doname.indexOf(mainDomain)!=-1);}else
  158. {condition=(doname==mainDomain);}
  159. if(condition)
  160. {if(arr[i].href.toLowerCase().indexOf("mailto:")!=-1&&arr[i].href.toLowerCase().indexOf("tel:")==-1)
  161. {var gaUri=arr[i].href.match(/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/);_tagClicks(arr[i],'Mailto',gaUri[0],'',0);}
  162. else if(arr[i].href.toLowerCase().indexOf("mailto:")==-1&&arr[i].href.toLowerCase().indexOf("tel:")!=-1)
  163. {_tagClicks(arr[i],'Telephone Clicks',arr[i].href.split("tel:")[1],'',0);}
  164. else if(arr[i].href.toLowerCase().indexOf("mailto:")==-1&&arr[i].href.toLowerCase().indexOf("tel:")==-1)
  165. {for(var j=0;j<extDoc.length;j++)
  166. {var arExt=arr[i].href.split(".");var ext=arExt[arExt.length-1].split(/[#?&?]/);if(ext[0].toLowerCase()==extDoc[j])
  167. {_tagClicks(arr[i],'Download',ext[0].toLowerCase(),arr[i].href.split(/[#?&?]/)[0],0);break;}}}}
  168. else
  169. {for(var l=0;l<extDoc.length;l++)
  170. {var arExt=arr[i].href.split(".");var ext=arExt[arExt.length-1].split(/[#?]/);if(ext[0].toLowerCase()==extDoc[l])
  171. {var gaUri=arr[i].href.split(extDoc[l]);_tagClicks(arr[i],'Outbound Downloads',ext[0].toLowerCase(),arr[i].href.split(/[#?&?]/)[0],0);break;}
  172. else if(ext[0].toLowerCase()!=extDoc[l])
  173. {flagExt++;if(flagExt==extDoc.length)
  174. {if(arr[i].href.toLowerCase().indexOf("mailto:")==-1&&arr[i].href.toLowerCase().indexOf("tel:")==-1)
  175. {_tagClicks(arr[i],'Outbound',arr[i].hostname,arr[i].pathname,0);}
  176. else if(extDoc.length&&arr[i].href.toLowerCase().indexOf("mailto:")!=-1&&arr[i].href.toLowerCase().indexOf("tel:")==-1)
  177. {var gaUri=arr[i].href.match(/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/);_tagClicks(arr[i],'Outbound MailTo',gaUri[0],'',0);}
  178. else if(extDoc.length&&arr[i].href.toLowerCase().indexOf("mailto:")==-1&&arr[i].href.toLowerCase().indexOf("tel:")!=-1)
  179. {_tagClicks(arr[i],'Telephone Clicks',arr[i].href.split("tel:")[1],'',0);}}}}}}}
  180. if(oCONFIG.YOUTUBE.toString()=='true')
  181. {var videoArray_fed=new Array();var playerArray_fed=new Array();var _f33=false;var _f66=false;var _f90=false;var tag=document.createElement('script');tag.src="//www.youtube.com/player_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);function youtube_parser_fed(url){var regExp=/^(https?\:)?(\/\/)?(www\.)?(youtu\.be\/|youtube(\-nocookie)?\.([A-Za-z]{2,4}|[A-Za-z]{2,3}\.[A-Za-z]{2})\/)(watch|embed\/|vi?\/)?(\?vi?\=)?([^#\&\?\/]{11}).*$/;var match=url.match(regExp);if(match&&match[9].length==11){return match[9];}else{}}
  182. function IsYouTube_fed(url){var YouTubeLink_regEx=/^(https?\:)?(\/\/)?(www\.)?(youtu\.be\/|youtube(\-nocookie)?\.([A-Za-z]{2,4}|[A-Za-z]{2,3}\.[A-Za-z]{2})\/)(watch|embed\/|vi?\/)?(\?vi?\=)?([^#\&\?\/]{11}).*$/;if(YouTubeLink_regEx.test(url.toString()))
  183. {return true;}
  184. else
  185. {return false;}}
  186. function YTUrlHandler_fed(url)
  187. {url=url.replace(/origin\=(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})\&?/ig,'origin='+document.location.protocol+'//'+document.location.host);stAdd='';adFlag=false;if(url.indexOf('https')==-1){url=url.replace('http','https');}
  188. if(url.indexOf('?')==-1){stAdd='?flag=1';}
  189. if(url.indexOf('enablejsapi')==-1){stAdd+='&enablejsapi=1';adFlag=true;}
  190. if(url.indexOf('html5')==-1){stAdd+='&html5=1';adFlag=true;}
  191. if(url.indexOf('origin')==-1){stAdd+='&origin='+document.location.protocol+'//'+document.location.host;adFlag=true;}
  192. if(adFlag==true)
  193. {return url+stAdd;}
  194. else
  195. {return url;}}
  196. function _initYouTubeTracker(){var _iframes=document.getElementsByTagName('iframe');var vArray=0;for(var ytifrm=0;ytifrm<_iframes.length;ytifrm++){_thisVideoObj=_iframes[ytifrm];var _thisSrc=_thisVideoObj.src;if(IsYouTube_fed(_thisSrc)){_thisVideoObj.src=YTUrlHandler_fed(_thisSrc);var youtubeid=youtube_parser_fed(_thisSrc);_thisVideoObj.setAttribute('id',youtubeid);videoArray_fed[vArray]=youtubeid;vArray++;}}}
  197. function onYouTubePlayerAPIReady(){for(var i=0;i<videoArray_fed.length;i++){playerArray_fed[i]=new YT.Player(videoArray_fed[i],{events:{'onReady':onFedPlayerReady,'onStateChange':onFedPlayerStateChange}});}}
  198. function onFedPlayerReady(event){}
  199. function onFedPlayerStateChange(event){var videoURL=event.target.getIframe().getAttribute('src');var videoId=youtube_parser_fed(videoURL);_thisDuration=((parseInt(event.target.getCurrentTime())/ parseInt(event.target.getDuration()))*100).toFixed();if(typeof onPlayerStateChange!="undefined"){onPlayerStateChange(event);}
  200. if(parseInt(event.data)==parseInt(YT.PlayerState.PLAYING)){if(_thisDuration==0){_f33=false;_f66=false;_f90=false;}
  201. _sendEvent('YouTube Video','play',videoURL,0);}else if(event.data==YT.PlayerState.ENDED){_sendEvent('YouTube Video','finish',videoURL,0);}else if(event.data==YT.PlayerState.PAUSED){_sendEvent('YouTube Video','pause',videoURL,0);var duration=_thisDuration;if(duration<100){var precentage=_thisDuration;if(precentage>0&&precentage<=33&&_f33==false){_sendEvent('YouTube Video','33%',videoURL,0);}else if(precentage>0&&precentage<=66&&_f66==false){_sendEvent('YouTube Video','66%',videoURL,0);}else if(precentage>0&&precentage<=90&&_f90==false){_sendEvent('YouTube Video','90%',videoURL,0);}}}}}
  202. function _initIdAssigner(){var _allDocLinks=document.getElementsByTagName('a');for(var sid=0;sid<_allDocLinks.length;sid++){var currentId=_allDocLinks[sid].getAttribute('id');if(currentId==null||currentId==''||currentId==undefined){_allDocLinks[sid].setAttribute('id','anch_'+sid);}}}
  203. function _tagClicks(evObj,evCat,evAct,evLbl,evVal)
  204. {if(evObj.addEventListener)
  205. {evObj.addEventListener('mousedown',function(){_sendEvent(evCat,evAct,evLbl,evVal);});}
  206. else if(evObj.attachEvent)
  207. {evObj.attachEvent('onmousedown',function(){_sendEvent(evCat,evAct,evLbl,evVal);});}}
  208. if(document.addEventListener)
  209. {document.addEventListener('DOMContentLoaded',function(){if(tObjectCheck!=window["GoogleAnalyticsObject"])
  210. {createTracker(false);}
  211. oCONFIG.ENHANCED_LINK.toString()=='true'?_initIdAssigner():'';oCONFIG.AUTOTRACKER.toString()=='true'?_initAutoTracker():'';oCONFIG.YOUTUBE.toString()=='true'?_initYouTubeTracker():'';});}
  212. else if(document.attachEvent)
  213. {document.attachEvent('onreadystatechange',function(){if(document.readyState==="complete")
  214. {if(tObjectCheck!=window["GoogleAnalyticsObject"])
  215. {createTracker(false);}
  216. oCONFIG.ENHANCED_LINK.toString()=='true'?_initIdAssigner():'';oCONFIG.AUTOTRACKER.toString()=='true'?_initAutoTracker():'';oCONFIG.YOUTUBE.toString()=='true'?_initYouTubeTracker():'';}});}