Skip to content

GA and GTM updates #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ alphabetical order):
- Alexey Bazhin
- Andreas Sieferlinger
- Antoine Pitrou
- Brent Bandelgar (@brentbb)
- Cédric Bosdonnat
- Christophe-Marie Duquesne
- @datro
Expand Down
1 change: 1 addition & 0 deletions sigal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'destination': '_build',
'files_to_copy': (),
'google_analytics': '',
'google_tag_manager': '',
'ignore_directories': [],
'ignore_files': [],
'img_processor': 'ResizeToFit',
Expand Down
3 changes: 3 additions & 0 deletions sigal/templates/sigal.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
# Google Analytics tracking code (UA-xxxx-x)
# google_analytics = ''

# Google Tag Manager tracking code (GTM-xxxxxx)
# google_tag_manager = ''

# Piwik tracking
# tracker_url must not contain trailing slash.
# Example : {'tracker_url': 'http://stats.domain.com', 'site_id' : 2}
Expand Down
3 changes: 2 additions & 1 deletion sigal/themes/colorbox/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
</style>
{% endif %}
{% endblock %}
{% include 'analytics.html' %}
</head>
<body>
{% include 'gtm.html' %}
<div class="container">
<div class="four columns">
<div class="sidebar">
Expand All @@ -45,7 +47,6 @@ <h1><a href="{{ album.index_url }}">{{ index_title }}</a></h1>
</div>

{% block footer %}{% endblock %}
{% include 'analytics.html' %}
{% include 'piwik.html' %}
</body>
</html>
17 changes: 8 additions & 9 deletions sigal/themes/default/templates/analytics.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% if settings.google_analytics %}
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ settings.google_analytics }}']);
_gaq.push(['_trackPageview']);
(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','https://www.google-analytics.com/analytics.js','ga');

(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>
ga('create', '{{ settings.google_analytics }}', 'auto');
ga('send', 'pageview');

</script>
{% endif %}
11 changes: 11 additions & 0 deletions sigal/themes/default/templates/gtm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% if settings.google_tag_manager %}
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={{settings.google_tag_manager}}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{settings.google_tag_manager}}');</script>
<!-- End Google Tag Manager -->
{% endif %}
3 changes: 2 additions & 1 deletion sigal/themes/galleria/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
<style type="text/css">
</style>
{% endif %}
{% include 'analytics.html' %}
</head>
<body>
{% include 'gtm.html' %}
<div class="container">
<header>
<h1><a href="{{ album.index_url }}">{{ index_title }}</a></h1>
Expand Down Expand Up @@ -303,7 +305,6 @@ <h2>

</script>
{% endif %}
{% include 'analytics.html' %}
{% include 'piwik.html' %}
</body>
</html>
3 changes: 2 additions & 1 deletion sigal/themes/photoswipe/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
<script src="{{ theme.url }}/photoswipe-ui-default.min.js"></script>
<script src="{{ theme.url }}/echo/echo.min.js"></script>
{% endblock %}
{% include 'analytics.html' %}
</head>
<body>
{% include 'gtm.html' %}
<div class="container">
<h1><a href="{{ album.index_url }}">{{ index_title }}</a></h1>

Expand Down Expand Up @@ -396,7 +398,6 @@ <h2>
{% endif %}
{% endblock %}
</div>
{% include 'analytics.html' %}
{% include 'piwik.html' %}
</body>
</html>