codethechange / codethechange.github.io

Stanford Code the Change's website.
https://codethechange.stanford.edu
MIT License
0 stars 2 forks source link

add google analytics tag #33

Closed DrewGregory closed 4 years ago

DrewGregory commented 5 years ago

I just added a Google Analytics script so that we can get some basic statistics on the site traffic.

U8NWXD commented 5 years ago

I agree with the IP anonymization! We really don't need that level of geographic precision

U8NWXD commented 5 years ago

What about turning the Google Analytics cookies into session cookies? Based on the docs, we can set cookie_expires to 0 to turn the tracking cookie into a session cookie that expires once the user closes the browser. That would look like this:

gtag('config', 'GA_MEASUREMENT_ID', {
  cookie_expires: 0
});

Alternatively, we could set cookie_expires to something like 24 * 60 * 60 to make the cookie expire after 24 hours. If we set cookie_update to false, then the cookie will be deleted 24 hours after it was set, so we'll only ever have 24 hours worth of visits associated with a given user identifier. By the way, I'm making up the 24 hour number; we can discuss what the right value is. This might look like this:

gtag('config', 'GA_MEASUREMENT_ID', {
  cookie_expires: 24 * 60 * 60,  // 24 hours
  cookie_update: false
});
U8NWXD commented 5 years ago

And we should strongly consider disabling data sharing with Google per these instructions

DrewGregory commented 4 years ago

This definitely is a big decision. I'll hold off on this for later.