• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #13176

pending completion
#13176

push

circleci

rhelmer
clean up the GA4 blob

282 of 1627 branches covered (17.33%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

959 of 4380 relevant lines covered (21.89%)

1.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/views/partials/analytics.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import AppConstants from '../../app-constants.js'
6

7
export const analytics = nonce => `
×
8
<script nonce='${nonce}' async
9
  src="https://www.googletagmanager.com/gtag/js?id=${AppConstants.GA4_MEASUREMENT_ID}">
10
</script>
11
<script nonce='${nonce}'>
12
  if (navigator.doNotTrack === '1') {
13
    function gtag() {
14
      console.debug("Google Analytics disabled by DNT")
15
    }
16
  } else {
17
    window.dataLayer = window.dataLayer || []
18
    function gtag() {
19
      dataLayer.push(arguments)
20
    }
21
    gtag('js', new Date())
22
    gtag('config', '${AppConstants.GA4_MEASUREMENT_ID}', {
23
      cookie_domain: window.location.hostname,
24
      cookie_flags: "SameSite=None;Secure",
25
      debug_mode: '${Boolean(AppConstants.GA4_DEBUG_MODE)}'
26
    })
27

28
    // Instrument CTA clicks for analytics.
29
    document.querySelectorAll('[data-cta-id]').forEach(a =>
30
      a.addEventListener('click', e => {
31
        gtag('event', 'clicked_cta', { cta_id: a.dataset.ctaId })
32
      }
33
    ))
34
  }
35
  window.gtag = gtag
36
</script>
37
`
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc