analytics.js

This commit is contained in:
mdipierro committed 2012-12-12 21:30:57 -06:00
1 parent 12ff451f4b
commit 0015a265a9
4 files changed
+21 -5

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Version 2.3.0 (2012-12-12 21:13:40) rc1
Version 2.3.0 (2012-12-12 21:30:14) rc1
+5 -2
View File
@@ -5,6 +5,8 @@
## Customize your APP title, subtitle and menus here
#########################################################################
response.logo = A(B('web',SPAN(2),'py'),XML('™ '),
_class="brand",_href="http://www.web2py.com/")
response.title = ' '.join(
word.capitalize() for word in request.application.split('_'))
response.subtitle = T('customize me!')
@@ -26,11 +28,12 @@ response.menu = [
(T('Home'), False, URL('default', 'index'), [])
]
DEVELOPMENT_MENU = True
#########################################################################
## provide shortcuts for development. remove in production
#########################################################################
def _():
# shortcuts
app = request.application
@@ -133,4 +136,4 @@ def _():
])
]
)]
_()
if DEVELOPMENT_MENU: _()
@@ -0,0 +1,6 @@
/*
from http://segmentio.github.com/analytics.js/
Copyright (C) 2012 Segment.io
MIT License
*/
(function(){var e=this,t=!1,n=new Date,r=!1,i=window.onload;window.onload=function(){r=!0,f(i)&&i()};var s=function(e){return Math.floor(new Date(e)/1e3)},o=function(e){if(!e)return;var t={};for(var n in e)t[n]=e[n];return t},u=function(e){return e===Object(e)},a=function(e){return Object.prototype.toString.call(e)==="[object String]"},f=function(e){return Object.prototype.toString.call(e)==="[object Function]"},l=/.+\@.+\..+/,c=function(e,t){if(!a(e)&&!u(e))throw new Error("Encountered unresolvable settings value.");if(a(e)){var n=e;e={},e[t]=n}return e};e.analytics||(e.analytics={providers:[],userId:null,initialize:function(e){var n=[];for(var r in e){if(!h[r])throw new Error("Couldn't find a provider named \""+r+'"');h[r].initialize(e[r]),n.push(h[r])}this.providers=n,t=!0},identify:function(e,n){if(!t)return;u(e)&&(n=e,e=null),e!==null?this.userId=e:e=this.userId;for(var r=0,i;i=this.providers[r];r++){if(!i.identify)continue;var s=o(n);i.identify(e,s)}},track:function(e,n){if(!t)return;for(var r=0,i;i=this.providers[r];r++){if(!i.track)continue;var s=o(n);i.track(e,s)}}});var h={"Google Analytics":{initialize:function(e){this.settings=e=c(e,"trackingId");var t=t||[];t.push(["_setAccount",e.trackingId]);if(this.settings.enhancedLinkAttribution===!0){var n=("https:"==document.location.protocol?"https://ssl.":"http://www.")+"google-analytics.com/plugins/ga/inpage_linkid.js";t.push(["_require","inpage_linkid",n])}this.settings.siteSpeedSampleRate!=null&&typeof this.settings.siteSpeedSampleRate=="number"&&t.push(["_setSiteSpeedSampleRate",this.settings.siteSpeedSampleRate]),t.push(["_trackPageview"]),function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}(),window._gaq=t},track:function(e,t){window._gaq.push(["_trackEvent","All",e])}},KISSmetrics:{initialize:function(e){function n(e){setTimeout(function(){var t=document,n=t.getElementsByTagName("script")[0],r=t.createElement("script");r.type="text/javascript",r.async=!0,r.src=e,n.parentNode.insertBefore(r,n)},1)}this.settings=e=c(e,"apiKey");var t=t||[];n("//i.kissmetrics.com/i.js"),n("//doug1izaerwt3.cloudfront.net/"+e.apiKey+".1.js"),window._kmq=t},identify:function(e,t){e&&window._kmq.push(["identify",e]),t&&window._kmq.push(["set",t])},track:function(e,t){window._kmq.push(["record",e,t])}},Mixpanel:{initialize:function(e){this.settings=e=c(e,"token"),function(e,t){window.mixpanel=t;var n,r,i,s;n=e.createElement("script"),n.type="text/javascript",n.async=!0,n.src=("https:"===e.location.protocol?"https:":"http:")+"//cdn.mxpnl.com/libs/mixpanel-2.1.min.js",r=e.getElementsByTagName("script")[0],r.parentNode.insertBefore(n,r),t._i=[],t.init=function(e,n,r){function o(e,t){var n=t.split(".");2==n.length&&(e=e[n[0]],t=n[1]),e[t]=function(){e.push([t].concat(Array.prototype.slice.call(arguments,0)))}}var u=t;"undefined"!=typeof r?u=t[r]=[]:r="mixpanel",u.people=u.people||[],i=["disable","track","track_pageview","track_links","track_forms","register","register_once","unregister","identify","name_tag","set_config","people.identify","people.set","people.increment"];for(s=0;s<i.length;s++)o(u,i[s]);t._i.push([e,n,r])},t.__SV=1.1}(document,window.mixpanel||[]),window.mixpanel.init(e.token,e)},identify:function(e,t){e&&(window.mixpanel.identify(e),window.mixpanel.name_tag(e),l.test(e)&&(t=t||{},t.email=e)),t&&(this.aliasTraits(t),window.mixpanel.register(t)),this.settings.people===!0&&(e&&window.mixpanel.people.identify(e),t&&window.mixpanel.people.set(t))},aliasTraits:function(e){e.email&&(e.$email=e.email,delete e.email),e.name&&(e.$name=e.name,delete e.name),e.username&&(e.$username=e.username,delete e.username),e.lastSeen&&(e.$last_login=e.lastSeen,delete e.lastSeen),e.createdAt&&(e.$created=e.createdAt,delete e.createdAt)},track:function(e,t){window.mixpanel.track(e,t)}},Intercom:{initialize:function(e){this.settings=c(e,"appId")},identify:function(e,t){function n(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://api.intercom.io/api/js/library.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}if(!e)return;window.intercomSettings={app_id:this.settings.appId,user_id:e,custom_data:t||{}},t?(t.email&&(window.intercomSettings.email=t.email),t.name&&(window.intercomSettings.name=t.name),t.createdAt&&(window.intercomSettings.created_at=s(t.createdAt))):l.test(e)&&(window.intercomSettings.email=e),window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",n,!1)}},"Customer.io":{initialize:function(e){this.settings=e=c(e,"siteId");var t=t||[];(function(){var n,r,i;n=function(e){return function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}},r=["identify","track"];for(i=0;i<r.length;i++)t[r[i]]=n(r[i]);var s=document.createElement("script"),o=documentLine truncated
+9 -2
View File
@@ -76,7 +76,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="http://www.web2py.com/"><b>web<span>2</span>py</b>&trade;&nbsp;</a>
{{=response.logo or ''}}
<ul id="navbar" class="nav pull-right">{{='auth' in globals() and auth.navbar(mode="dropdown") or ''}}</ul>
<div class="nav-collapse">
{{is_mobile=request.user_agent().is_mobile}}
@@ -152,7 +152,14 @@
<script src="{{=URL('static','js/dd_belatedpng.js')}}"></script>
<script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-images </script>
<![endif]-->
{{if response.google_analytics_id:}}<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '{{=response.google_analytics_id}}']); _gaq.push(['_trackPageview']); (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); })(); </script> {{pass}}
{{if response.google_analytics_id:}}
<script src="{{=URL('static','js/analytics.js')}}"></script>
<script type="text/javascript">
analytics.initialize({
'Google Analytics':{trackingId:'{{=response.google_analytics_id}}'}
});</script>
{{pass}}
<script src="{{=URL('static','js/share.js',vars=dict(static=URL('static','images')))}}"></script>
</body>
</html>