outbreak-info / outbreak.info

During outbreaks of emerging diseases such as COVID-19, efficiently collecting, sharing, and integrating data is critical to scientific research. outbreak.info is a resource to aggregate all this information into a single location.
https://outbreak.info/
GNU General Public License v3.0
33 stars 13 forks source link

Use GAnalytics to expose what mutations people are searching for #287

Open flaneuse opened 3 years ago

flaneuse commented 3 years ago

e.g. trending lineages / variants / mutations

flaneuse commented 3 years ago

Vision: expose on outbreak.info/situation-reports the top 5 mutation searches over the past 2 or 4 weeks, which will be some combination of lineage reports, lineage + added mutations reports, and mutation(s) reports.

Steps:

  1. Need to switch Google Analytics tracking from sending the Vue view name to a dynamic title as the page_title. This has been done in the dynamic-titles branch BUT since the Google Analytics fires before vue-meta changes the page title, the GA page view is the PREVIOUS route, not the current one.
    • This will convert the page titles into: "B.1.1.7 Lineage Report", "B.1.1.7 Lineage with S:E484K Report", "S:S13I, S:L452R Variant Report", "S:S13I Mutation Report", so we can aggregate based on pango and muts query params and ignore the rest.
    • This is necessary because while the path variable has all the info we need, it also contains lots of other things (e.g. location data) that we want to track but don't need for this analysis. The parsing of paths like outbreak.info/situation-reports?pango=B.1.1.7 (to extract B.1.1.7) could happen on the front-end, but that's not ideal.
  2. This is a known issue between vue-meta and vue-gtag: https://github.com/nuxt-community/google-analytics-module/issues/8, but I haven't had time to sort out a solution.
  3. Alternatively, we could try to store/pass the title parameter from the SituationReport in vue-router; I took a brief look but couldn't figure out how to dynamically attach it to the meta object or something similar of the route.
  4. Other alternative idea: only pass the pango and muts params from the route to object. Problem with that: would work for Situation Reports, but we don't want to break how the rest of the site passes titles to GA.
  5. Verify that the GA pages are firing properly locally before deploying. Will need to remove the localhost filter from the GA settings to test this out.
  6. Pull the top 5 or 10 mutation report searches from the GA API: https://ga-dev-tools.appspot.com/query-explorer/ (see params below)
  7. Incorporate GA API key (safely!) onto the prod server to make the API call.
  8. Parse the page titles (or find some other way to pass the info) to link the page titles to their route, e.g. "B.1.1.7 Lineage Report" == outbreak.info/situation-reports?pango=B.1.1.7
  9. Expose the queries on /situation-reports Screen Shot 2021-03-04 at 6 23 34 PM