usds / justice40-tool

A tool to identify disadvantaged communities due to environmental, socioeconomic and health burdens
https://screeningtool.geoplatform.gov/
Creative Commons Zero v1.0 Universal
130 stars 42 forks source link

As a J40 team member, I want to see site analytics, so I understand how visitors are using the site. #49

Closed switzersc-usds closed 2 years ago

switzersc-usds commented 3 years ago

Description We need to define what analytics we want to capture from the beginning and set up an analytics tool to do so. We may get some logging and analytics out of the box with our hosting solution, but instrumenting on the client side will give us better insights on our audience and how visitors use the site. Insights will help us answer questions such as, are users in geographies with overburdened communities accessing our site? Is content in one language being accessed more than another?

Solution Identify and implement an analytics tool on the site. I advocate for using an open source, privacy-oriented tool like Matomo as opposed to Google Analytics, but we would need to sort out hosting for this.

Describe alternatives you've considered

Not having an analytics tool: However, if we can get insights from the outset, we should. It's easier to start out with the right tooling than add later.

Links to user research or other resources

Tasks

Identify what metrics would be most useful to capture about site traffic
Research what tools we're able to use
Pick on that meets our needs and constraints and implement

Definition of "Done"

switzersc-usds commented 3 years ago

We can probably identify the questions we want to ask / metrics to capture during/before sprint grooming.

glennettec commented 3 years ago

Using the Digital Analytics Platform (DAP) will link the site to analytics.usa.gov. It is a unified GA account for government agencies.

GH: https://github.com/18F/analytics.usa.gov

GSA DAP 4.1 - DAP Code Capabilities Summary and Reference

GSA DAP 4.1 - Quick Guide

switzersc-usds commented 2 years ago

@glennettec will own documenting what we need to do and how long it takes for getting on DAP.

switzersc-usds commented 2 years ago

Prioritizing this as a way to understand usage and also serve the purpose of some basic uptime and front-end monitoring (eg if there are zero users for over a certain period of time, something may be up and we should investigate).

switzersc-usds commented 2 years ago

We have next steps here and will proceed after we get the URL and cert sorted out.

glennettec commented 2 years ago

Below is the DAP GA code that should be placed at the top of tag. <script async type="text/javascript" id="_fed_an_ua_tag" src="https://dap.digitalgov.gov/Universal-Federated-Analytics- Min.js?agency=DOI&sitetopic=cejst&enhlink=true"></script>

vim-usds commented 2 years ago

Based on the conservation today with @glennettec and seeing the GA dashboard, a few things I learned:

  1. The GA dashboard tracks analytics for a number of agencies, DOI being one of them. When selecting DOI as the top level filter on the dashboard, a number of domains are show up under DOI. The DOI has many domains being tracked (via GA code snippet placed in the head) and our screening tool is one of those domains. @switzersc-usds it does sound like any site can use the snippet and it will be under the DOI umbrella.
  2. When choosing some random domains (that are under DOI and thus using the same code we are) and investigating their head tag, we see that the script tag is at the bottom of the head tag (same like in our case) and furthermore, the other google analytics tags that were under question on our site also exist on these random domains within DOI.

Next steps:

  1. Get access to the dashboard for faster troubleshooting
  2. Figure out if certification is required to see more than 1 domain
  3. Go over the implementation guide that was provided by @glennettec (thank you)
  4. See if the analytics plugin for Gatsby could be the reason. About page is equivalent to the index page and wondering if page architecture of gatsby is somehow preventing this?
  5. Investigate using React-head over react-helmet

Open to any other ideas as well.

vim-usds commented 2 years ago

Sent email requesting access to GA dashboard for DOI..... fingers crossed!

vim-usds commented 2 years ago

This pdf explains two ways to install the GA code snippet. One interesting bit of info that opposes earlier findings... "The best location of the script block is directly before the closing tag" - page 2 of the manual. This is where React Helmet places the script tag. It seems that we actually get to choose which agency the screening tool analytics belongs under. Breaking down the GA link:

"https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=DOI&sitetopic=cejst&enhlink=true"

url https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js

1st query param: ?agency=DOI &

2nd query param: sitetopic=cejst &

3rd query param: enhlink=true

The first query string of the src URL in the GA code snippet makes sense to me, agency=DOI. (Thanks @glennettec). We set that and this does work in the dashboard.

Investigating sitetopic and enhlink as to their purpose meaning and/or relevance.

I wonder if enhlink causes the other GA link to show up in the head?

<script type="text/javascript" async="" src="https://www.google-analytics.com/plugins/ua/linkid.js"></script>
vim-usds commented 2 years ago

Page 11 breaks down the query strings nicely!

Screen Shot 2021-09-21 at 5 12 17 PM Screen Shot 2021-09-21 at 5 12 39 PM

What's interesting is that the enhlink doesn't seem to be supported by GA. What was the reasoning behind including that in the code snippet @glennettec ? More of a curiosity thing as I don't think it's related to the other pages not showing up on the GA dashboard.

vim-usds commented 2 years ago

Updating with email conversation with DAP customer support:

Thank you.

I have reached out to my colleague to get a screen shot. In the meantime, would it be possible to grant me access to the “Govt wide main reporting” in DAP?

I remember being on this exact site with my colleague with the only difference being that instead of “Govt wide main reporting”, we were looking under the DOI agency. This agency query string is also set in our script tag (sent in original email).

Yes this site belongs to EOP / OMB. That’s the org I’m with. I’m working under Lisa Chung (Engineering Director of USDS)

RE: Firing twice (great catch by the way!)

When I place the following script in the HEAD via (React Helmet)…

<script async           type="text/javascript"           id="_fed_an_ua_tag"           src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=DOI&sitetopic=cejst&enhlink=true">         

for some reason the following two script tags are added (along with the above for a total of 3 script tags in the HEAD):

When I remove the enhlink query strings like so… <script async           type="text/javascript"           id="_fed_an_ua_tag"           src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=DOI&sitetopic=cejst">         

then only one extra script tag shows up (for a total of 2 script tags in the HEAD):

Removing agency or sitetopic from the query strings still produces the same 2 script tags in the HEAD.

I really appreciate your help. I feel I could troubleshoot this if I had access to some GA dashboard. Thanks for all your support and looking forward to hearing from you tmrw.

Vim Shah (he/him/his)

From: "Freddie (DAP)" dap@support.digitalgov.gov Reply-To: DAP dap@support.digitalgov.gov Date: Wednesday, September 22, 2021 at 2:05 PM To: "Shah, Vim K. EOP/OMB" Vimal.K.Shah@omb.eop.gov Subject: Re: Requesting access to DOI Google Analytics dashboard: request updated

In replies all text above this line is added to the ticket

Freddie (TTS Solutions Support) Sep 22, 2021, 2:05 PM EDT Hello: Thanks for your note. You've reached the GSA. We don't have access to the specific reports you reference or know if you're viewing DAP or possibly another GA account. 

Follow up feedback:

  1. Why are other pages on the above URL not showing up in the analytics? Is this an analytics thing or is the frontend framework need some adjusting? --> This appears to be a single page app and this is the likely culprit - please confirm here if you're using a SPA.
  2. What other query parameters could be added to customize the analytics experience (page 11 of DAP Quick Guide (https://github.com/digital-analytics-program/gov-wide-code/blob/master/documentation/GSA%20DAP%204.1%20-%20Quick%20Guide.pdf) )? --> Please provide the snippet that you implemented and we'll review it - I don't see it in your source code. 
  3. Could downloading the JS file locally help test the integration of the DAP analytics (page 3 of DAP Quick Guide (https://github.com/digital-analytics-program/gov-wide-code/blob/master/documentation/GSA%20DAP%204.1%20-%20Quick%20Guide.pdf) )? --> Best practice is to reference the universally hosted file. I suspect your CMS framework is causing issues with tracking. 

Freddie Freddie Blicher DAP Analyst Digital Analytics Program analytics.usa.gov Demonstrate your knowledge by becoming a DAP Certified Analyst! More information here. DAP v4.1 is out! If you call our code from a local server, it's time to update. More information here.  

Shah, Vim K. EOP/OMB Sep 22, 2021, 12:39 PM EDT Thank you very much for your response. Thanks for your note. What is the site URL you're wishing to implement DAP on? The aforementioned script has been added to the following site: * >main site< Glennette has access the GA dashboard / reporting and according to her, it seems that the index page (title = About) does show up in the analytics. This is a good first step indicating that the script tag may have been implemented correctly. What I’m troubleshooting now:

  1. Why are other pages on the above URL not showing up in the analytics? Is this an analytics thing or is the frontend framework need some adjusting?
  2. What other query parameters could be added to customize the analytics experience (page 11 of DAP Quick Guide (https://github.com/digital-analytics-program/gov-wide-code/blob/master/documentation/GSA%20DAP%204.1%20-%20Quick%20Guide.pdf) )?
  3. Could downloading the JS file locally help test the integration of the DAP analytics (page 3 of DAP Quick Guide (https://github.com/digital-analytics-program/gov-wide-code/blob/master/documentation/GSA%20DAP%204.1%20-%20Quick%20Guide.pdf) )? My request is for access to the GA dashboard to view some or all of the domain under the DOI agency so that I can compare how other domains have added their tracking and compare it to our URL mentioned above. Also to help me troubleshoot the issues listed above. Thank you very much for your support. PS: If it’s easier to jump on a call or zoom, please let me know. Cheers. Vim Shah (he/him/his)

 

Freddie (TTS Solutions Support) Sep 22, 2021, 9:06 AM EDT Hello: Thanks for your note. What is the site URL you're wishing to implement DAP on?

Freddie Freddie Blicher DAP Analyst Digital Analytics Program analytics.usa.gov Demonstrate your knowledge by becoming a DAP Certified Analyst! More information here. DAP v4.1 is out! If you call our code from a local server, it's time to update. More information here.  

Shah, Vim K. EOP/OMB Sep 21, 2021, 6:59 PM EDT Hello, I am currently trying to integrate the following tracking code into Google Analytics for the Justice40 project. <script async type="text/javascript" id="_fed_an_ua_tag" src=">https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=DOI&sitetopic=cejst&enhlink=true<"> I am trying to figure out if the above code snippet is working correctly. I am working with Glennette and Shelby on the Justice 40 project. The code snippet partially works and we would like to increase our troubleshooting capacity. Would it be possible for me view the GA dashboard for the DOI agency? Currently Glennette is the only one with access. Thank you and looking forward to hearing back from you. Vim Shah (he/him/his) Software Engineer

vim-usds commented 2 years ago

Page title should be set at Climate and Economic Justice Tool | About. I wonder if the title will not be shown in the tab or if it will scroll into view. Once pages show up on GA, we can adjust the page title.

switzersc-usds commented 2 years ago

Since this is basically working and we can't further troubleshoot or add more functionality until we have a .gov domain in place, I'm going to close this for now. We also think that the robots.txt and sitemap will help (which is being done as part of the accessibility work). When we get our domain we can create a new issue if we have any problems with analytics functionality or need to modify it.