HL7 / ig-template-base

Base IG template managed by HL7 but usable by anyone (no logos). The foundation for most HL7-published IGs
14 stars 27 forks source link

Add ability to include Google analytics scripts in IG pages #256

Open ElliotSilver opened 3 weeks ago

ElliotSilver commented 3 weeks ago

To track page views, add following script just after </head> on every page of the IG.

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

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

G-ABCDE12345 should be replaced by a variable that can be specified in features.yml (?)

costateixeira commented 3 weeks ago

if we do this I would just make sure it is conditional to the existence of the google analytics ID, to make sure templates or IGs that don't provide the ID would not have broken javascript

ElliotSilver commented 3 weeks ago

@costateixeira, of course. That would also give people who don't want google tracking to avoid it.

ElliotSilver commented 3 weeks ago

This is a followup to HL7/fhir-ig-publisher#383 which was interpreted to only request a way to specify an ID, not to actually specify and use it.

grahamegrieve commented 3 weeks ago

This is a template thing, nothing to do with the publisher

costateixeira commented 3 weeks ago

Transferring to https://github.com/HL7/ig-template-base, where this belongs

ElliotSilver commented 1 week ago

I believe this works, in part, by putting a cookie on the client machine to track which pages that particular client navigates to. I think the google script includes an ability to integrate with a (perhaps third party) consent banner, so this shouldn't be a problem for people who need to worry about cookie consent. Use of the google tag is also an opt-in capability on the IG author's part, so this really shouldn't be an issue for authors who are concerned. However, @lmckenzi, you may want to confirm behaviour is acceptable to HL7 before making it the default for HL7 IGs.

ElliotSilver commented 1 week ago

We may also want to make it easy to replace the entire script with something more complex in a derived template. (I notice my website uses a modified script to filter out page views by the site admin, etc.).

costateixeira commented 1 week ago

Use of cookies is a decision by the author that impacts users. Do we need the common considerations about cookies, gdpr, consent, etc? I do not know what these cookies store from the user and i don't think we should ignore that. And if it requires a consent popup, does google analytics provide that?

On Sat, 9 Nov 2024, 19:07 Elliot Silver, @.***> wrote:

I believe this works, in part, by putting a cookie on the client machine to track which pages that particular client navigates to. I think the google script includes an ability to integrate with a (perhaps third party) consent banner, so this shouldn't be a problem for people who need to worry about cookie consent. Use of the google tag is also an opt-in capability on the IG author's part, so this really shouldn't be an issue for authors who are concerned. However, @lmckenzi https://github.com/lmckenzi, you may want to confirm behaviour is acceptable to HL7 before making it the default for HL7 IGs.

— Reply to this email directly, view it on GitHub https://github.com/HL7/ig-template-base/issues/256#issuecomment-2466359678, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3HUUDC7RG7O4TB5FWNUG3Z7ZFP5AVCNFSM6AAAAABQ67EDIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRWGM2TSNRXHA . You are receiving this because you were mentioned.Message ID: @.***>

ElliotSilver commented 1 week ago

As far as I can tell, you can use Google analytics without consent, or integrate with consent management in several ways. consent

Because this feature needs to be enabled, they will need to take action for cookies to be collected.

The reason it makes sense to be able to override the script, is to support more complex cases, like I mentioned above -- don't collect if I'm logged in as an admin user. However. I don't know how this works with our rules for active content in our templates.

costateixeira commented 1 week ago

My understanding is that consent management is always needed if you track IPs. "if your website uses Google Analytics and targets users in the European Union, a cookie disclaimer is required under the General Data Protection Regulation (GDPR). Google Analytics uses cookies to track and analyze website traffic, and these cookies collect personal data, such as IP addresses, which falls under GDPR regulation."

image

I am sure Google has tools to help, but we should just make sure that by default, the base template doesn't introduce risks