Skip to content

Commit

Permalink
add Google Analytics and Mixpanel tracking codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyri Tuulos committed Nov 26, 2012
1 parent 5aa6014 commit f2978ba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/conf.py
Expand Up @@ -101,7 +101,11 @@
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
html_theme_options = {
'google_analytics_id': 'UA-26067752-1',
'google_analytics_domain': 'bitdeli.com',
'mixpanel_id': '567215920088e776cce6d7c00cbd58dc',
}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['../themes']
Expand Down
25 changes: 25 additions & 0 deletions themes/solar/layout.html
Expand Up @@ -41,3 +41,28 @@
{%- endif %}
</div>
{%- endblock %}

{%- block extrahead %}
{%- if theme_google_analytics_id %}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ theme_google_analytics_id }}']);
{%- if theme_google_analytics_domain %}
_gaq.push(['_setDomainName', '{{ theme_google_analytics_domain }}']);
{%- endif %}
_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>
{%- endif %}
{%- if theme_mixpanel_id %}
<script type="text/javascript">
(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.1.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f?
g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config get_distinct_id people.identify people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
mixpanel.init("{{ theme_mixpanel_id }}");
</script>
{%- endif %}
{%- endblock %}
5 changes: 5 additions & 0 deletions themes/solar/theme.conf
Expand Up @@ -2,3 +2,8 @@
inherit = basic
stylesheet = solar.css
pygments_style = none

[options]
google_analytics_id =
google_analytics_domain =
mixpanel_id =

0 comments on commit f2978ba

Please sign in to comment.