Skip to content

Commit

Permalink
Generalize analytics support in default theme
Browse files Browse the repository at this point in the history
As the number of privacy-preserving analytics options proliferates,
it no longer makes sense to support specific solutions provided by
ad-tracking corporations.
  • Loading branch information
justinmayer committed Aug 3, 2023
1 parent 5435dd0 commit 639173d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 49 deletions.
2 changes: 1 addition & 1 deletion docs/publish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Deployment

After you have generated your site, previewed it in your local development
environment, and are ready to deploy it to production, you might first
re-generate your site with any production-specific settings (e.g., analytics
re-generate your site with any production-specific settings (e.g., analytics,
feeds, etc.) that you may have defined::

pelican content -s publishconf.py
Expand Down
19 changes: 10 additions & 9 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1245,18 +1245,19 @@ Feel free to use them in your themes as well.
Your GitHub URL (if you have one). It will then use this information to
create a GitHub ribbon.

.. data:: GOOGLE_ANALYTICS
.. data:: ANALYTICS

Set to ``UA-XXXXX-Y`` Property's tracking ID to activate Google Analytics.
Put any desired analytics scripts in this setting in ``publishconf.py``.
Example:

.. data:: GA_COOKIE_DOMAIN

Set cookie domain field of Google Analytics tracking code. Defaults to
``auto``.

.. data:: GOSQUARED_SITENAME
.. parsed-literal::
Set to 'XXX-YYYYYY-X' to activate GoSquared.
ANALYTICS = """
<script src="/theme/js/primary-analytics.js"></script>
<script>
[ … in-line Javascript code for secondary analytics … ]
</script>
"""
.. data:: MENUITEMS

Expand Down
27 changes: 2 additions & 25 deletions pelican/themes/notmyidea/templates/analytics.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
{% if GOOGLE_ANALYTICS %}
<script type="text/javascript">
(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');

ga('create', '{{GOOGLE_ANALYTICS}}', '{{GA_COOKIE_DOMAIN if GA_COOKIE_DOMAIN else 'auto'}}');
ga('send', 'pageview');
</script>
{% endif %}
{% if GAUGES %}
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '{{GAUGES}}');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
{% if ANALYTICS %}
{{ ANALYTICS }}
{% endif %}
14 changes: 0 additions & 14 deletions pelican/themes/simple/templates/gosquared.html

This file was deleted.

0 comments on commit 639173d

Please sign in to comment.