Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
Add analytics and metrika
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Oct 2, 2012
1 parent bf25923 commit f8bed4f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
12 changes: 8 additions & 4 deletions base/core/templates/core/base.html
Expand Up @@ -17,16 +17,17 @@
{% block body_content %}

{# Navbar #}
{% block navigation %}
{% include 'core/blocks/nav.html' %}
{% endblock %}
{% block navigation %}{% include 'core/blocks/nav.html' %}{% endblock %}

{% include "core/blocks/messages.html" %}
{# Messages #}
{% block messages %}{% include "core/blocks/messages.html" %}{% endblock %}

{# Content #}
<div class="container">
{% block page_content %}{% endblock %}
</div>

{# Footer #}
{% block footer %}
<style type="text/css" media="screen">
.footer {
Expand All @@ -42,4 +43,7 @@
</footer>
{% endblock %}

{% if config.get('FOUNDATION_METRIKA') %} {% include "core/blocks/metrika.html" %} {% endif %}
{% if config.get('FOUNDATION_ANALYTICS') %} {% include "core/blocks/analytics.html" %} {% endif %}

{% endblock %}
11 changes: 11 additions & 0 deletions base/core/templates/core/blocks/analytics.html
@@ -0,0 +1,11 @@
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', "{{ config['FOUNDATION_ANALYTICS'] }}"]);
_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>
23 changes: 23 additions & 0 deletions base/core/templates/core/blocks/metrika.html
@@ -0,0 +1,23 @@
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter{{ config.get('FOUNDATION_METRIKA') }} = new Ya.Metrika({id:{{ config.get('FOUNDATION_METRIKA') }}, enableAll: true});
} catch(e) { }
});

var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";

if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="//mc.yandex.ru/watch/{{ config.get('FOUNDATION_METRIKA') }}" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->

0 comments on commit f8bed4f

Please sign in to comment.