diff --git a/_includes/js-selector.html b/_includes/js-selector.html
index ec5c9a8..62a36e6 100644
--- a/_includes/js-selector.html
+++ b/_includes/js-selector.html
@@ -8,38 +8,34 @@
{% if page.layout == 'home' %}
-
+
{% elsif page.layout == 'post' %}
-
+
{% if page.math %}
-
+
{% endif %}
{% elsif page.layout == 'page' %}
{% if page.type == 'categories' %}
-
+
{% else %}
-
+
{% endif %}
{% else %}
-
+
{% endif %}
{% if jekyll.environment == 'production' %}
-
- {% include google-analytics.html %}
-
-
-
+
{% endif %}
diff --git a/_layouts/default.html b/_layouts/default.html
index 03047bf..4b4b34c 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -54,6 +54,10 @@ layout: compress
{% include search-loader.html %}
+ {% if site.google_analytics.id and jekyll.environment == 'production' %}
+ {% include google-analytics.html %}
+ {% endif %}
+