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

removed google tag manager + disabled analytics #283

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@

<script type="module" src="/src/index.ts"></script>

<!-- Google Tag Manager tag (gtm.js) - 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-KWWTRTX');</script>

<!-- Google rich results card -->
<script type="application/ld+json">
{
Expand All @@ -63,7 +60,6 @@
</script>
</head>
<body>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KWWTRTX" height="0" width="0" style="display:none;visibility:hidden"></iframe>
<div class="container-xxl">
<vmd-app>
<h1 slot="main-title">
Expand Down
131 changes: 72 additions & 59 deletions src/utils/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,51 @@ declare global {

export class Analytics {
public static readonly INSTANCE = new Analytics();
private readonly analyticsEnabled = false;

protected constructor() {
}

navigationSurNouvellePage(nomPage: string) {
window.dataLayer.push({
'event': 'change_screen',
'site_name' : 'vite_ma_dose',
'page_type' : nomPage
});
if(this.analyticsEnabled) {
window.dataLayer.push({
'event': 'change_screen',
'site_name' : 'vite_ma_dose',
'page_type' : nomPage
});
}
}

clickSurRdv(lieu: Lieu, triCentre: CodeTriCentre|'unknown', searchType: SearchType, commune: Commune|undefined) {
window.dataLayer.push({
'event': 'rdv_click',
'rdv_departement' : lieu.departement,
'rdv_commune' : commune?`${commune.codePostal} - ${commune.nom} (${commune.code})`:undefined,
'rdv_platform' : lieu.plateforme,
'rdv_name': lieu.nom,
'rdv_location_type' : lieu.type,
'rdv_vaccine' : lieu.vaccine_type,
'rdv_sort_type' : triCentre,
'rdv_filter_type' : [`kind:${searchType}`].join("|")
});
if(this.analyticsEnabled) {
window.dataLayer.push({
'event': 'rdv_click',
'rdv_departement': lieu.departement,
'rdv_commune': commune ? `${commune.codePostal} - ${commune.nom} (${commune.code})` : undefined,
'rdv_platform': lieu.plateforme,
'rdv_name': lieu.nom,
'rdv_location_type': lieu.type,
'rdv_vaccine': lieu.vaccine_type,
'rdv_sort_type': triCentre,
'rdv_filter_type': [`kind:${searchType}`].join("|")
});
}
}

clickSurVerifRdv(lieu: Lieu, triCentre: CodeTriCentre|'unknown', searchType: SearchType, commune: Commune|undefined) {
window.dataLayer.push({
'event': 'rdv_verify',
'rdv_departement' : lieu.departement,
'rdv_commune' : commune?`${commune.codePostal} - ${commune.nom} (${commune.code})`:undefined,
'rdv_platform' : lieu.plateforme,
'rdv_name': lieu.nom,
'rdv_location_type' : lieu.type,
'rdv_vaccine' : lieu.vaccine_type,
'rdv_sort_type' : triCentre,
'rdv_filter_type' : [`kind:${searchType}`].join("|")
});
if(this.analyticsEnabled) {
window.dataLayer.push({
'event': 'rdv_verify',
'rdv_departement': lieu.departement,
'rdv_commune': commune ? `${commune.codePostal} - ${commune.nom} (${commune.code})` : undefined,
'rdv_platform': lieu.plateforme,
'rdv_name': lieu.nom,
'rdv_location_type': lieu.type,
'rdv_vaccine': lieu.vaccine_type,
'rdv_sort_type': triCentre,
'rdv_filter_type': [`kind:${searchType}`].join("|")
});
}
}

static analyticsForJourSelectionne(jourSelectionne: string|undefined) {
Expand All @@ -68,44 +75,50 @@ export class Analytics {
}

clickSurJourRdv(jourSelectionne: string | undefined, typeSelectionDate: "auto" | "manual" | undefined, total: number) {
const jourSelectionneAnalytics = Analytics.analyticsForJourSelectionne(jourSelectionne);
window.dataLayer.push({
'event': 'appointment_day_selection',
'daily_appointments' : total,
'date_selection_type': typeSelectionDate,
'selected_date': jourSelectionne,
'selected_date_diff': jourSelectionneAnalytics.diffDays,
'selected_weekday': jourSelectionneAnalytics.weekday,
});
if(this.analyticsEnabled) {
const jourSelectionneAnalytics = Analytics.analyticsForJourSelectionne(jourSelectionne);
window.dataLayer.push({
'event': 'appointment_day_selection',
'daily_appointments': total,
'date_selection_type': typeSelectionDate,
'selected_date': jourSelectionne,
'selected_date_diff': jourSelectionneAnalytics.diffDays,
'selected_weekday': jourSelectionneAnalytics.weekday,
});
}
}

rechercheLieuEffectuee(codeDepartement: CodeDepartement, triCentre: CodeTriCentre|'unknown', searchType: SearchType, typeSelectionDate: 'auto'|'manual'|undefined, jourSelectionne: string|undefined, commune: Commune|undefined, resultats: LieuxAvecDistanceParDepartement|undefined) {
const jourSelectionneAnalytics = Analytics.analyticsForJourSelectionne(jourSelectionne);
window.dataLayer.push({
'event': commune?'search_by_commune':'search_by_departement',
'search_departement': codeDepartement,
'search_commune' : commune?`${commune.codePostal} - ${commune.nom} (${commune.code})`:undefined,
'search_nb_appointments' : resultats?resultats.lieuxDisponibles.reduce((totalDoses, lieu) => totalDoses+lieu.appointment_count, 0):undefined,
'search_nb_lieu_vaccination' : resultats?resultats.lieuxDisponibles
.filter(isLieuActif)
.length:undefined,
'search_nb_lieu_vaccination_inactive' : resultats?resultats.lieuxDisponibles
.filter(l => !isLieuActif(l))
.length:undefined,
'search_sort_type': triCentre,
'search_filter_type' : [`kind:${searchType}`].join("|"),
'date_selection_type': typeSelectionDate,
'selected_date': jourSelectionne,
'selected_date_diff': jourSelectionneAnalytics.diffDays,
'selected_weekday': jourSelectionneAnalytics.weekday,
});
if(this.analyticsEnabled) {
const jourSelectionneAnalytics = Analytics.analyticsForJourSelectionne(jourSelectionne);
window.dataLayer.push({
'event': commune ? 'search_by_commune' : 'search_by_departement',
'search_departement': codeDepartement,
'search_commune': commune ? `${commune.codePostal} - ${commune.nom} (${commune.code})` : undefined,
'search_nb_appointments': resultats ? resultats.lieuxDisponibles.reduce((totalDoses, lieu) => totalDoses + lieu.appointment_count, 0) : undefined,
'search_nb_lieu_vaccination': resultats ? resultats.lieuxDisponibles
.filter(isLieuActif)
.length : undefined,
'search_nb_lieu_vaccination_inactive': resultats ? resultats.lieuxDisponibles
.filter(l => !isLieuActif(l))
.length : undefined,
'search_sort_type': triCentre,
'search_filter_type': [`kind:${searchType}`].join("|"),
'date_selection_type': typeSelectionDate,
'selected_date': jourSelectionne,
'selected_date_diff': jourSelectionneAnalytics.diffDays,
'selected_weekday': jourSelectionneAnalytics.weekday,
});
}
}

critereTriCentresMisAJour(triCentre: CodeTriCentre) {
window.dataLayer.push({
'event': 'sort_change',
'sort_changed_to' : triCentre,
});
if(this.analyticsEnabled) {
window.dataLayer.push({
'event': 'sort_change',
'sort_changed_to': triCentre,
});
}
}

}