From c79b818302de1d4f49490b0f1623e2b6266ed593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=A4KayJayDee?= Date: Mon, 7 Jul 2025 18:06:43 +0200 Subject: [PATCH] =?UTF-8?q?feat(analytics):=20int=C3=A9gration=20de=20Goog?= =?UTF-8?q?le=20Analytics=20et=20mise=20=C3=A0=20jour=20du=20sitemap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remplacement de Google Tag Manager par Google Analytics (gtag.js) dans index.html pour le suivi des performances. - Ajout d'une fonction de suivi des pages vues dans le routeur pour améliorer l'analyse des données. - Mise à jour des dates de dernière modification dans sitemap.xml pour refléter la date actuelle. - Révision des règles dans robots.txt pour un meilleur contrôle d'indexation. --- index.html | 28 ++++++++++---------- public/robots.txt | 29 ++------------------- public/sitemap.xml | 62 +++++++++++++-------------------------------- src/router/index.ts | 36 +++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 90 deletions(-) diff --git a/index.html b/index.html index 628350d..2ad6184 100644 --- a/index.html +++ b/index.html @@ -5,16 +5,19 @@ - - - + + + + + + Full Stack Developer Freelance Vue.js React Node.js | Killian Dalcin @@ -238,11 +241,6 @@ - - - -
diff --git a/public/robots.txt b/public/robots.txt index 207f806..a81fcb5 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,30 +1,5 @@ -# Robots.txt pour killiandalcin.fr -# Optimisé pour un crawling Google efficace - -# Googlebot -User-agent: Googlebot -Allow: / -Crawl-delay: 0 - -# Bingbot -User-agent: Bingbot -Allow: / -Crawl-delay: 1 - -# Tous les bots légitimes User-agent: * -Allow: / -Disallow: /api/ Disallow: /admin/ -Disallow: /*.json$ +Disallow: /api/ Disallow: /*?* -Allow: /*.css$ -Allow: /*.js$ -Allow: /*.webp$ -Allow: /*.jpg$ -Allow: /*.png$ -Allow: /*.svg$ -Allow: /*.woff2$ - -# Sitemap -Sitemap: https://killiandalcin.fr/sitemap.xml \ No newline at end of file +Sitemap: https://killiandalcin.fr/sitemap.xml \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml index e406a59..89a5864 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -3,52 +3,40 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> - + https://killiandalcin.fr/ - 2025-01-14 - weekly - 1.0 + 2025-07-07 - + https://killiandalcin.fr/fiverr - 2025-01-14 - weekly - 0.9 + 2025-07-07 https://killiandalcin.fr/projects - 2025-01-14 - weekly - 0.8 + 2025-07-07 https://killiandalcin.fr/contact - 2025-01-14 - monthly - 0.8 + 2025-07-07 https://killiandalcin.fr/about - 2025-01-14 - monthly - 0.7 + 2025-07-07 https://killiandalcin.fr/formation - 2025-01-14 - monthly - 0.7 + 2025-07-07 @@ -56,57 +44,43 @@ https://killiandalcin.fr/project/virtual-tour - 2025-01-14 - monthly - 0.6 + 2025-07-07 - + https://killiandalcin.fr/project/xinko - 2025-01-14 - monthly - 0.7 + 2025-07-07 - + https://killiandalcin.fr/project/image-manipulation - 2025-01-14 - monthly - 0.7 + 2025-07-07 - + https://killiandalcin.fr/project/flowboard - 2025-01-14 - monthly - 0.7 + 2025-07-07 https://killiandalcin.fr/project/primate-web-admin - 2025-01-14 - monthly - 0.6 + 2025-07-07 https://killiandalcin.fr/project/instagram-bot - 2025-01-14 - monthly - 0.6 + 2025-07-07 https://killiandalcin.fr/project/crowdin-status-bot - 2025-01-14 - monthly - 0.6 + 2025-07-07 \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 277d687..9075136 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,7 +1,15 @@ -import { createRouter, createWebHistory } from 'vue-router' +import { createRouter, createWebHistory, type RouteLocationNormalized } from 'vue-router' import { nextTick } from 'vue' import HomePage from '../views/HomePage.vue' +// Google Analytics gtag types +declare global { + interface Window { + dataLayer: unknown[] + gtag: (...args: unknown[]) => void + } +} + const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ @@ -94,9 +102,20 @@ router.beforeEach((to, from, next) => { next() }) -// Additional scroll to top handler for better compatibility -router.afterEach(() => { - // Use nextTick to ensure the DOM is fully updated +// Google Analytics page view tracking function +const trackPageView = (route: RouteLocationNormalized) => { + // Track page view with gtag + if (window.gtag) { + window.gtag('config', 'G-CDVVNFY6MV', { + page_path: route.path, + page_title: document.title, + page_location: window.location.href + }) + } +} + +// Track page views on route changes +router.afterEach((to) => { nextTick(() => { // Smooth scroll to top window.scrollTo({ @@ -104,7 +123,16 @@ router.afterEach(() => { left: 0, behavior: 'smooth' }) + + // Track page view for GTM + trackPageView(to) }) }) +// Track initial page load +router.isReady().then(() => { + // Track the initial route after router is ready + trackPageView(router.currentRoute.value) +}) + export default router