@@ -42,7 +42,7 @@ frontend:
4242 site_name: this.SITE_NAME
4343 });
4444
45- console.log(\`✅ Google Analytics 4 initialized with ID: \${this.GA4_MEASUREMENT_ID}\`);
45+ console.log(\`â
Google Analytics 4 initialized with ID: \${this.GA4_MEASUREMENT_ID}\`);
4646 }
4747
4848 // Method to track custom events
@@ -53,7 +53,7 @@ frontend:
5353 event_label: label,
5454 value: value
5555 });
56- console.log(\`📊 GA4 Event tracked: \${action} (\${category})\`);
56+ console.log(\`ð GA4 Event tracked: \${action} (\${category})\`);
5757 }
5858 }
5959
@@ -66,6 +66,117 @@ frontend:
6666 });
6767 }
6868 }
69+
70+ // Enhanced tracking methods for comprehensive analytics
71+ trackKeyEvent(action, details = {}) {
72+ if (window.gtag) {
73+ gtag('event', action, {
74+ event_category: 'key_interaction',
75+ custom_parameters: details,
76+ ...details
77+ });
78+ console.log(\`🔑 Key Event tracked: \${action}\`, details);
79+ }
80+ }
81+
82+ trackNavigation(item, location = '') {
83+ if (window.gtag) {
84+ gtag('event', 'navigation_click', {
85+ event_category: 'navigation',
86+ nav_item: item,
87+ nav_location: location
88+ });
89+ console.log(\`🧭 Navigation tracked: \${item} at \${location}\`);
90+ }
91+ }
92+
93+ trackModal(action, modalName) {
94+ if (window.gtag) {
95+ gtag('event', \`modal_\${action}\`, {
96+ event_category: 'modal_interaction',
97+ modal_name: modalName
98+ });
99+ console.log(\`📱 Modal tracked: \${action} - \${modalName}\`);
100+ }
101+ }
102+
103+ trackAIInteraction(provider, action, details = {}) {
104+ if (window.gtag) {
105+ gtag('event', 'ai_interaction', {
106+ event_category: 'ai_usage',
107+ ai_provider: provider,
108+ ai_action: action,
109+ ...details
110+ });
111+ console.log(\`🤖 AI Interaction tracked: \${provider} - \${action}\`, details);
112+ }
113+ }
114+
115+ trackDocumentOperation(operation, details = {}) {
116+ if (window.gtag) {
117+ gtag('event', 'document_operation', {
118+ event_category: 'document_management',
119+ doc_operation: operation,
120+ ...details
121+ });
122+ console.log(\`📄 Document Operation tracked: \${operation}\`, details);
123+ }
124+ }
125+
126+ trackResearchOperation(operation, details = {}) {
127+ if (window.gtag) {
128+ gtag('event', 'research_operation', {
129+ event_category: 'research_activity',
130+ research_operation: operation,
131+ ...details
132+ });
133+ console.log(\`🔬 Research Operation tracked: \${operation}\`, details);
134+ }
135+ }
136+
137+ trackChatInteraction(method, details = {}) {
138+ if (window.gtag) {
139+ gtag('event', 'chat_interaction', {
140+ event_category: 'chat_usage',
141+ interaction_method: method,
142+ ...details
143+ });
144+ console.log(\`💬 Chat Interaction tracked: \${method}\`, details);
145+ }
146+ }
147+
148+ // Device and capability tracking
149+ trackDeviceInfo() {
150+ if (window.gtag) {
151+ const deviceInfo = {
152+ screen_resolution: \`\${screen.width}x\${screen.height}\`,
153+ viewport_size: \`\${window.innerWidth}x\${window.innerHeight}\`,
154+ user_agent: navigator.userAgent,
155+ platform: navigator.platform,
156+ language: navigator.language,
157+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
158+ connection_type: navigator.connection ? navigator.connection.effectiveType : 'unknown',
159+ device_memory: navigator.deviceMemory || 'unknown',
160+ hardware_concurrency: navigator.hardwareConcurrency || 'unknown'
161+ };
162+
163+ gtag('event', 'device_info', {
164+ event_category: 'device_analytics',
165+ ...deviceInfo
166+ });
167+
168+ console.log('📱 Device Info tracked:', deviceInfo);
169+ }
170+ }
171+
172+ // Debug helper
173+ debugAnalytics() {
174+ console.log('🔍 Analytics Debug Info:');
175+ console.log(' - GA4 ID:', this.GA4_MEASUREMENT_ID);
176+ console.log(' - gtag available:', !!window.gtag);
177+ console.log(' - dataLayer length:', window.dataLayer ? window.dataLayer.length : 0);
178+ console.log(' - Available methods:', Object.getOwnPropertyNames(Object.getPrototypeOf(this)));
179+ }
69180 }
70181
71182 // Create global config instance
0 commit comments