Skip to content

Commit

Permalink
Merge branch 'development' into feat/pageviews-ga4
Browse files Browse the repository at this point in the history
  • Loading branch information
p3rcypj committed Apr 26, 2024
2 parents 278a319 + 83b0c92 commit ef715c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=%REACT_APP_GOOGLE_ANALYTICS_4%"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', '%REACT_APP_GOOGLE_ANALYTICS_4%');
</script>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/icon-sm.png" sizes="192x192" />
<link rel="icon" href="%PUBLIC_URL%/icon-small.png" sizes="192x192" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,6 @@ const dhisVersions = [
{ value: "2.36", text: "2.36" },
{ value: "2.37", text: "2.37" },
{ value: "2.38", text: "2.38" },
{ value: "2.39", text: "2.39" },
{ value: "2.40", text: "2.40" },
];
15 changes: 15 additions & 0 deletions src/webapp/utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function sendAnalytics(name: string, data?: object) {
if (!window.gtag) throw new Error("gtag() function has not been declared.");
window.gtag(
"event",
name,
data
// Relevant params to track. Only add if the client allows it
// data && {
// ...data,
// location_hash: window.location.hash,
// location_pathname: window.location.pathname,
// location_href: window.location.href,
// }
);
}

0 comments on commit ef715c9

Please sign in to comment.