Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public Sans - Bug: GA4 tracking code troubleshooting #337

Open
2 tasks done
amycole501 opened this issue Jan 28, 2025 · 6 comments · May be fixed by #338
Open
2 tasks done

Public Sans - Bug: GA4 tracking code troubleshooting #337

amycole501 opened this issue Jan 28, 2025 · 6 comments · May be fixed by #338
Assignees
Labels

Comments

@amycole501
Copy link

Describe the bug

No data is coming into the GA4 report. It's possible it's because there is now duplicate code on the page. We should troubleshoot until the data appears. Related to issue #322

Please let me know once the update is made and I can refresh the data in GA4 (probably wait a day or so) then check to see if it's working. If removing the code doesn't work we can continue to troubleshoot.

Steps to reproduce the bug

  1. Go to https://public-sans.digital.gov/
  2. Inspect page source
  3. Scroll to the bottom; see the google tag manager code at the very bottom
--   | <script async src="https://www.googletagmanager.com/gtag/js?id=UA-47271808-2"></script>   | <script>   | window.dataLayer = window.dataLayer \|\| [];   | function gtag(){dataLayer.push(arguments);}   | gtag('js', new Date());   |     | gtag('config', 'UA-47271808-2');

Expected Behavior

This code is the only GA4 tracking code needed on the site along with instructions:

Below is the Google tag for this account. Copy and paste it in the code of every page of your website, immediately after the element. Don’t add more than one Google tag to each page.

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

Related code

No response

Screenshots

No response

System setup

No response

Additional context

No response

Code of Conduct

@amycole501 amycole501 added Added during Sprint Needs: Confirmation We need to confirm that this is an issue Type: Bug A problem in the code labels Jan 28, 2025
@github-actions github-actions bot added the Status: Triage We're triaging this issue and grooming if necessary label Jan 28, 2025
@amycole501 amycole501 removed the Needs: Confirmation We need to confirm that this is an issue label Jan 28, 2025
@mejiaj mejiaj self-assigned this Jan 28, 2025
@mejiaj mejiaj moved this to On deck in USWDS Core Project Data Jan 28, 2025
@mejiaj mejiaj removed the Status: Triage We're triaging this issue and grooming if necessary label Jan 28, 2025
@thisisdano
Copy link
Member

Let's confirm that code. Here's what's in this issue:

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

Here's what's currently in the head:

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

The difference is the gtag information at the end.

New: gtag('config', ' gtag('config', 'G-HBYXWFP794');
Old: gtag('config', 'G-HBYXWFP794');

The new config section is the one that looks wrong. Amy, can you confirm?

@amycole501
Copy link
Author

@thisisdano just forwarded you an email where I copied the new tracking code. You can double check but I copied the code below out of the email from the tracking team:

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

It's possible we should reach out to the tracking team to confirm there's not an issue.

@mejiaj mejiaj moved this from On deck to In progress in USWDS Core Project Data Jan 29, 2025
mejiaj added a commit that referenced this issue Jan 29, 2025
@mejiaj mejiaj linked a pull request Jan 29, 2025 that will close this issue
@mejiaj
Copy link
Contributor

mejiaj commented Jan 29, 2025

@amycole501 you can use three backticks at the start and end of code to make a code block1.

Alternatively, you can highlight your block of code and press the code button. It should create the block for you.

Image


The tag you mentioned shows gtag twice:

gtag('config', ' gtag('config'

Image

But aside from that it matches what's currently in the <head> element in #338.

Footnotes

  1. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks

@amycole501
Copy link
Author

The code is now working; there was a missing filter at the property level that someone on the data side fixed for us.

However the code at the bottom of the page still needs to be removed. It's not helping to collect any information and is unnecessary:

Image

See note above under "expected behavior" for not having double code added to the site. Once completed let me know to make sure to check in GA4 that the code is still collecting data appropriately.

@mejiaj mejiaj moved this from In progress to Peer Review in USWDS Core Project Data Jan 29, 2025
@mejiaj
Copy link
Contributor

mejiaj commented Jan 29, 2025

@mejiaj mejiaj moved this from Peer Review to Fed Final Review in USWDS Core Project Data Jan 29, 2025
@mejiaj
Copy link
Contributor

mejiaj commented Jan 29, 2025

Ready for your review @thisisdano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Fed Final Review
Development

Successfully merging a pull request may close this issue.

3 participants