Update google_analytics fragment, add support for GA_COOKIE_DOMAIN

Per Pelican simple theme and Google Analytics documentation:
- https://developers.google.com/analytics/devguides/collection/analyticsjs
- https://github.com/getpelican/pelican/blob/master/pelican/themes/notmyidea/templates/analytics.html
This commit is contained in:
Arnaud Rebillout
2020-07-26 14:22:47 +07:00
parent a6a9b79389
commit 8a20068fe6
+9 -8
View File
@@ -1,10 +1,11 @@
{% if GOOGLE_ANALYTICS %} {% if GOOGLE_ANALYTICS %}
<script type="text/javascript"> <script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (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), (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) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ GOOGLE_ANALYTICS }}', 'auto');
ga('send', 'pageview'); ga('create', '{{ GOOGLE_ANALYTICS }}', '{{ GA_COOKIE_DOMAIN if GA_COOKIE_DOMAIN else 'auto' }}');
</script> ga('send', 'pageview');
</script>
{% endif %} {% endif %}