Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
add google analytics
Browse files Browse the repository at this point in the history
works with CSP and respects DNT
  • Loading branch information
LeoMcA committed Oct 25, 2023
1 parent e6b9c22 commit ba16961
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"homepage": "https://github.com/mozilla/http-observatory-website#readme",
"dependencies": {
"@mozmeao/dnt-helper": "^1.0.0",
"bootstrap": "^4.3.1",
"chart.js": "^2.8.0",
"dayjs": "^1.8.15",
Expand Down
16 changes: 16 additions & 0 deletions src/js/ga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import dntEnabled from "@mozmeao/dnt-helper";

if (!dntEnabled()) {
var gaScript = document.createElement("script");
gaScript.async = 1;
gaScript.src = "https://www.googletagmanager.com/gtag/js?id=G-0YL01S2FDK";
document.head.appendChild(gaScript);

window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "G-0YL01S2FDK");
}
1 change: 1 addition & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import constants from './constants.js';
import statistics from './statistics.js';
import thirdParty from './third-party/third-party.js';
import utils from './utils.js';
import './ga.js';

window.$ = $;

Expand Down

0 comments on commit ba16961

Please sign in to comment.