BCDevOps / developer-experience

This repository is used to track all work for the BCGov Platform Services Team (This includes work for: 1. Platform Experience, 2. Developer Experience 3. Platform Operations/OCP 3)
Apache License 2.0
8 stars 17 forks source link

Research analytics solutions for Private Cloud websites #3070

Closed ty2k closed 1 year ago

ty2k commented 1 year ago

Research and document the options for adding analytics (visitor tracking) code to our Private Cloud websites and document the options in this ticket.

Additional context

How does this benefit the users of our platform? Having visitor analytics for our content sites will show us which content is most viewed, least viewed, how long people spend on pages, and other important metrics. This will inform how we edit and promote current content, create new content, and retire unused/unneeded content.

Definition of done

ty2k commented 1 year ago

GDX Analytics option

The GDX Analytics product is a combination of a Snowplow tracker script that gets served to the user's browser by your front-end code, plus a Looker business intelligence dashboard that generates reports and graphs based on the data generated by Snowplow. The product has a cost associated with it to cover licenses for Looker and for the setup/maintenance of the product and user groups.

WordPress sites using GDX Analytics option

The "BCGov Looker Snowplow" plugin is already active in our WordPress sites at cloud.gov.bc.ca and no custom development would be necessary on our part. A base monthly charge would apply for the integration plus one user group that covers all users in the site network. Having a single user group would mean that the Platform Services team's data is combined with data from other sites in the network (SaaS, Public Cloud, etc), and users would use URL filters to view stats for just their own sites (ex: the SaaS team would filter their results by URLs like https://cloud.gov.bc.ca/saas/*). There would be an additional charge for each additional team if there was a need to segment the data by site.

Tech Docs site using GDX Analytics option

The Tech Docs site is a Gatsby site using Reach router. There is not currently a code sample from the GDX Analytics team for an integration like this, so we would be building our own with their troubleshooting help. They do have a React example using react-router-dom that will help with this effort. There are a number of Gatsby analytics plugins (though none for Snowplow) that can also serve as examples for this work. The cost for this integration would change depending on whether we are using an existing user group from a WordPress integration or not. If we are not using an existing user group, the cost goes up to do that work here.

Non-GDX Analytics options

If we wanted to avoid paying for our analytics solution, we could look at building our own solution with open-source alternatives like Matomo, a widely used Google Analytics alternative for folks who need to control their analytics data for privacy reasons.

WordPress sites using Matomo for analytics

In WordPress, because we don’t have code access, we are at the mercy of what already exists for WordPress plugins for analytics. There is an official Matomo plugin that stores its data in the WordPress database. There is also a separate plugin for using an existing on-prem or cloud-hosted Matomo instance if we were to stand up a Matomo service on OpenShift to use with Tech Docs, described below.

Tech Docs site using Matomo for analytics

We could also build our own Matomo solution for the Tech Docs site, which would involve standing up a Matomo service on OpenShift and then building an integration with Gatsby to send analytics data to it. I see Patrick had a repository at bcgov/gatsby-source-matomo where he might have been trying to do part of this integration work for DevHub three years ago. There are also community plugins for Gatsby like gatsby-plugin-matomo that may offer drop-in support for Matomo. This will be a higher effort integration on our part than the WordPress integration due to the nature of routing in Single Page Applications and the lack of an existing Matomo service. The ongoing effort of maintaining a Matomo service should be taken into account with this option, and with the WordPress + Matomo on-prem/cloud option.