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

mozilla / blurts-server / #13175

pending completion
#13175

push

circleci

rhelmer
get ga4 to load in safari

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 = `
×
8
  if (navigator.doNotTrack === '1') {
9
    function gtag() {
10
      console.debug("Google Analytics disabled by DNT")
11
    }
12
  } else {
13
    // Use nonce to load gtag.js, @see https://developers.google.com/tag-platform/tag-manager/web/csp
14
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
15
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
16
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
17
    'https://www.googletagmanager.com/gtag/js?id='+i+dl;var n=d.querySelector('[nonce]');
18
    n&&j.setAttribute('nonce',n.nonce||n.getAttribute('nonce'));f.parentNode.insertBefore(j,f);
19
    })(window,document,'script','dataLayer','${AppConstants.GA4_MEASUREMENT_ID}');
20

21
    function gtag() {
22
      dataLayer.push(arguments);
23
    }
24
    gtag('js', new Date());
25
    gtag('config', '${AppConstants.GA4_MEASUREMENT_ID}', {
26
      cookie_domain: window.location.hostname,
27
      cookie_flags: "SameSite=None;Secure",
28
      debug_mode: '${Boolean(AppConstants.GA4_DEBUG_MODE)}'
29
    });
30

31
    // Detect CTA clicks on public pages.
32
    document.querySelectorAll('[data-cta-id]').forEach(a =>
33
      a.addEventListener('click', e => {
34
        gtag('event', 'clicked_cta', { cta_id: a.dataset.ctaId })
35
      }
36
    ))
37
  }
38
  window.gtag = gtag
39
`
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