DEV Community

Cover image for Google analytics, privacy, and personal blog
stereobooster
stereobooster

Posted on

Google analytics, privacy, and personal blog

I want to start my personal blog and I need analytics there. I want to use Hugo (or another static site generator) and host it with Netlify (or now, or S3 + CloudFlare). This means that I need to use 3-rd party service to collect analytics, right? I do not plan to monetize blog (do not know how?), so I don't want to pay for analytics service. I guess cheapest would be to rent DigitalOcean server for 5$ month (e.g. 60$ a year). But Google analytics costs 0$. On the other hand, I concerned about the privacy of my visitors.

Demo is here. Source code is here.

Current solution

For now, I decided to use Google analytics with ganalytics.

I ask for consent before saving any data to the user device

<div class="cookie" hidden>
  <p>
    Can we store cookies on your device? See <a href='{{ .Site.BaseURL }}privacy/'>Privacy Policy</a> for details.<br>
    <button type="button" class="cookie-yes">Yes</button> <button type="button" class="cookie-close">Close</button>
  </p>
</div>
Enter fullscreen mode Exit fullscreen mode

If I don't have consent I send anonymized request to Google analytics, but don't store any identifier on the device.

If I have consent I send a regular request with stored id.

There is a form with which the user can revoke consent and erase a locally stored identifier.

<form class="consent">
  You can revoke consent and remove unique identifier ("cookies") at any time using the form below.
  <noscript>This form needs JavaScript enabled in the browser in order to work</noscript>
  <br><br>
  <input type="radio" id="agree" name="consent" value="agree">
  <label for="agree">I <b>allow</b> to store a unique identifier on my computer to track my visits to this site.</label>
  <br><br>
  <input type="radio" id="disagree" name="consent" value="disagree">
  <label for="disagree">I <b> don't allow</b> to store unique identifier on my computer.</label>
</form>
Enter fullscreen mode Exit fullscreen mode

This form is on the page with the privacy policy, which explains that the website uses Google analytics and when data sent.

Remarketing feature is turned off. Advertising Reporting Features are turned off. I don't want to share data with Google.

I simply want to know a number of views of my posts, top source of traffic (search, social, referral), maybe region - nothing fancy.

WDYT

What do you think about my solution? Is it fair privacy-wise? Do I miss something?

Discussion (15)

Collapse
glennmen profile image
Glenn Carremans

I haven't tried it myself but I am really interested in Matomo (used to be Piwik), they are free if you host it yourself.

Collapse
stereobooster profile image
stereobooster Author

I wrote about this in article - the cheapest hosting I can think of is DIgitalOcean (I guess AWS will be cheaper but much more pain as well)

I guess cheapest would be to rent DigitalOcean server for 5$ month (e.g. 60$ a year)

So free = $60 year and I will need to maintain it myself (roll security patches etc)

There is github.com/usefathom/fathom as well.

Collapse
kmbremner profile image
Keith Bremner

You might be able to use Matomo on AWS free tier for a year?

Yes, it’s more work but it’s also a learning opportunity.

With free of charge saas like google analytics, it has to be worth it for the provider so you or your visitors are the product.

Thread Thread
stereobooster profile image
stereobooster Author

With free of charge saas like google analytics, it has to be worth it for the provider so you or your visitors are the product.

Yes I know. I wonder if strict privacy settings in GA would help to make it tolerable. It doesn't send cookies (so they don't know which user is that even if I logged into Gmail). I store (with permission) unique identifier in local storage (not in cookies). You can't really identify user outside of the website and no private information is stored. And you can erase it at any point. I can send anonymous IP flag.

Collapse
mrispoli24 profile image
Mike Rispoli

So I’ve been running keen.io alongside google for a site I manage and I much prefer keen for drilling into the data. It has an auto collector script that works much like ga would except you own all the data and it has ways to disable it in the case that users want to opt out. It has a generous free tier and is very inexpensive after that. For a site with about 1k monthly uniques it ran about $1.50 a month on average.

As another plus it’s highly customizable so you can capture interesting stats and behaviors and embed cool dataviz graphs where you want.

Collapse
stereobooster profile image
stereobooster Author • Edited on

Interesting. Price is nice. I wonder if they are GDPR compliant (They are in the US as far as I can see).

Collapse
jacebenson profile image
Jace • Edited on

So here's my question. How do any analytics help you?
I mean, it can tell you how popular a page is and where your traffic is from sometimes, but outside of those two reasons, what is the purpose of using analytics?

If the thing you are looking for is just how popular your page is but it isn't driving any action, maybe consider removing them entirely.

About 2 years ago I had Google Analytics and I decided I'm done with Google and Facebook. So I moved to clicky. Then once I had that data, I realized, it was neat to see... but, it wasn't actionable.

There was literally nothing I gained from this information. It wasn't going to drive the content I write. So a few months ago I removed them entirely. Now the only "analytics" i have is from my algolia search, and those things are actionable. Searched terms and searched terms with no results. Now I have a list of pages to make/update.

I'd love to hear your feedback @stereobooster on this.

Collapse
stereobooster profile image
stereobooster Author

1.

I mean, it can tell you how popular a page is and where your traffic is from sometimes, but outside of those two reasons, what is the purpose of using analytics?

This is what I basically need (from my post):

I simply want to know a number of views of my posts, top source of traffic (search, social, referral), maybe region - nothing fancy.

2.

If the thing you are looking for is just how popular your page is but it isn't driving any action, maybe consider removing them entirely.

Knowing that my posts are viewed keeps me motivated as an author. This is the main reason.

Others would be:

  • using referral information I can find places where my posts being discussed
  • the popularity of content doesn't drive what I write but it may drive how I write it. I do experiments: I write in different styles, using different types of titles and see if people like one over another
  • pure curiosity: where are my visitors from
  • I can use analytics to report JS errors, so I know my readers have troubles
  • I wonder on which devices (screen sizes) my content is most viewed, so I can check how my website looks like for different people
  • I can check which kind of search queries brings me the most traffic. And compare it to my expectations (are those random queries or queries related to my content)
  • I can use analytics to report 404 errors
  • github.com/guess-js/guess or github.com/browserslist/browsersli...
Collapse
stereobooster profile image
stereobooster Author

This maybe an option netlify.com/products/analytics/

  • Pageviews & unique visitors
  • Bandwidth used
  • Top sources & pages
  • Top resources not found
  • GDPR compliant
  • No performance loss
  • Only $9/month per site
Collapse
nataliedeweerd profile image
𝐍𝐚𝐭𝐚𝐥𝐢𝐞 𝐝𝐞 𝐖𝐞𝐞𝐫𝐝

Apologies if I missed this in your article, but why not just use Google Analytics directly? Why are you using Ganalytics?

Collapse
stereobooster profile image
stereobooster Author

Ganalytics is 312B

stereobooster profile image
stereobooster Author

Nice. I'm not really an expert in hosting providers. I wonder if any of those have servers in EU

stereobooster profile image
stereobooster Author

Thanks. You are very helpful. This remind me about blog.simpleanalytics.io/why-we-mov...