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

mozilla / blurts-server / #13193

pending completion
#13193

push

circleci

toufali
refactor GA analytics to use import module

282 of 1631 branches covered (17.29%)

Branch coverage included in aggregate %.

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

959 of 4393 relevant lines covered (21.83%)

1.82 hits per line

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

0.0
/src/client/js/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
const GA4_MEASUREMENT_ID = 'G-CXG8K4KW4P'
×
6

7
if (navigator.doNotTrack === '1') {
×
8
  window.gtag = function() {
×
9
    console.debug("Google Analytics disabled by DNT")
×
10
  }
11
  window.gtag()
×
12
} else {
13
  await import(`https://www.googletagmanager.com/gtag/js?id=${GA4_MEASUREMENT_ID}`)
×
14

15
  window.dataLayer = window.dataLayer || []
×
16

17
  window.gtag = function() {
×
18
    window.dataLayer.push(arguments)
×
19
  }
20
  window.gtag('js', new Date())
×
21
  window.gtag('config', GA4_MEASUREMENT_ID, {
×
22
    cookie_domain: window.location.hostname,
23
    cookie_flags: "SameSite=None;Secure"
24
  })
25

26
  // Instrument CTA clicks for analytics.
27
  document.querySelectorAll('[data-cta-id]').forEach(a =>
×
28
    a.addEventListener('click', e => {
×
29
      gtag('event', 'clicked_cta', { cta_id: a.dataset.ctaId })
×
30
    }
31
  ))
32
}
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