@@ -412,7 +412,6 @@ import axios from 'axios';
412412import Plotly from ' plotly.js-dist-min' ;
413413import JSZip from ' jszip' ;
414414import { saveAs } from ' file-saver' ;
415- import { event } from " vue-gtag" ;
416415
417416// --- API CONFIGURATION ---
418417// 1. Get the URL (Localhost in dev, Ngrok in prod)
@@ -428,6 +427,16 @@ const apiClient = axios.create({
428427 }
429428});
430429
430+ // --- NATIVE GOOGLE ANALYTICS TRACKING ---
431+ const trackEvent = (eventName , params = {}) => {
432+ if (typeof window .gtag === ' function' ) {
433+ window .gtag (' event' , eventName, params);
434+ console .log (` ?? GA Event Sent: ${ eventName} ` , params);
435+ } else {
436+ console .log (` ?? GA Event Skipped (Not loaded): ${ eventName} ` );
437+ }
438+ };
439+
431440// --- CONSTANTS ---
432441// Colors for selected points (cycles through this list)
433442const COLORS = [
@@ -654,11 +663,13 @@ const onMapClick = async (e) => {
654663 if (selectedPoints .value .length >= 10 ) return ;
655664
656665 // Track clicks
657- event (" map_click" , {
658- event_category: " interaction" ,
659- event_label: " extract_timeseries" ,
660- region: currentRegion .value // Tracks 'Greenland' or 'Antarctica'
661- });
666+ trackEvent (" map_click" , {
667+ event_category: " interaction" ,
668+ event_label: " extract_timeseries" ,
669+ region: currentRegion .value ,
670+ lat: e .latlng .lat .toFixed (4 ),
671+ lon: e .latlng .lng .toFixed (4 )
672+ });
662673
663674 const newId = Date .now ();
664675 const color = COLORS [selectedPoints .value .length % COLORS .length ];
@@ -863,12 +874,13 @@ const downloadChartImage = async () => {
863874 }
864875
865876 // Track png downloads
866- event (" download" , {
867- event_category: " export" ,
868- event_label: " png_chart" ,
869- plot_type: currentPlotVar .value
870- });
871-
877+ trackEvent (" file_download" , {
878+ event_category: " export" ,
879+ event_label: " png_chart" ,
880+ file_extension: " png" ,
881+ file_name: ` velocity_plots_${ currentRegion .value } ` ,
882+ plot_type: currentPlotVar .value
883+ });
872884
873885 statusMessage .value = " Generating image(s)..." ;
874886
@@ -931,12 +943,14 @@ const handleDownload = async () => {
931943 if (selectedPoints .value .length === 0 ) return ;
932944
933945 // Track csv downloads
934- event (" download" , {
935- event_category: " export" ,
936- event_label: " csv_data" ,
937- region: currentRegion .value ,
938- count: selectedPoints .value .length
939- });
946+ trackEvent (" file_download" , {
947+ event_category: " export" ,
948+ event_label: " csv_data" ,
949+ file_extension: " zip" , // or csv
950+ file_name: " velocity_data_batch" ,
951+ region: currentRegion .value ,
952+ count: selectedPoints .value .length
953+ });
940954
941955 // Single File: Direct CSV download
942956 if (selectedPoints .value .length === 1 ) {
0 commit comments