codeforcroatia / popravi.to

This is popular map-based reporting platform FixMyStreet for Croatia named "Popravi.to"
http://popravi.to
Other
9 stars 7 forks source link

popravito: Add web analytics #123

Closed schlos closed 3 years ago

schlos commented 3 years ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Add Google Analytics & enable anonymize_ip. Add GoatCounter for backup (free under fair usage). Add Counter for cfc aggregated stats.

Describe alternatives you've considered

Additional context

Global site tag (gtag.js) Use this if you're using a website builder or CMS-hosted site Add the Analytics tag to your website to begin seeing data in your property. Copy the global site tag into the section of your HTML. Or, if you use a website builder (e.g. WordPress, Shopify, etc), copy the global site tag into your website builder’s custom HTML field.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8TW7QC6EF1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-8TW7QC6EF1');
</script>

Enable anonymize_ip:

https://support.google.com/analytics/answer/2763052?hl=en

https://developers.google.com/analytics/devguides/collection/gtagjs/ip-anonymization

(gtag('config', '', { 'anonymize_ip': true }) in the gtag.js library):

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8TW7QC6EF1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-8TW7QC6EF1', { 'anonymize_ip': true });
</script>
schlos commented 3 years ago

Done: