Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTM submission tracking #196

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/web/analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
declare global {
interface Window {
dataLayer: any[];
}
}

export const initDataLayer = () => {
window.dataLayer = window.dataLayer || [];
};

export const pushToDataLayer = (event: string) => {
window.dataLayer.push({
event,
});
};
26 changes: 26 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@
/>
<link rel="icon" href="./src/assets/favicon.ico" />
<title>DUMP Udruga mladih programera</title>

<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-WRPZN2L');
</script>
<!-- End Google Tag Manager -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-WRPZN2L"
height="0"
width="0"
style="display: none; visibility: hidden"
></iframe
></noscript>
<!-- End Google Tag Manager (noscript) -->

<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in apps/web/src/pages/ApplicationFormPage/ApplicationFormPage.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint (web)

Run autofix to sort these imports!
Discipline,
EducationOrEmploymentStatus,
FoundOutAboutInternshipBy,
Expand All @@ -17,6 +17,7 @@
import { disciplineLabel } from '../../constants/internConstants';
import { applicationFormDataQuestions } from './constants/ApplicationFormQuestions';
import classes from './index.module.css';
import { initDataLayer, pushToDataLayer } from '../../../analytics.ts';

export type FormValues = {
firstName: string;
Expand Down Expand Up @@ -77,6 +78,9 @@
},
};

initDataLayer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da li je potrebno da se initDataLayer poziva na svaki submit? Možda je dovoljno samo na prvi render page-a?

pushToDataLayer('internship_prijava');

try {
createIntern.mutate(internToSend);
} catch (err) {
Copy link
Contributor

@ToniGrbic ToniGrbic Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeli bolje da se pushToDataLayer poziva nakon createIntern.mutate jer je Stipe reka nakon upisivanja u bazu? Ili možda čak najbolje ako radi na onSuccess callback od useMutate hooka usePostIntern?

Expand Down
Loading