@@ -3369,10 +3369,12 @@ <h3>Ready to Search</h3>
33693369 . filter ( tutorial => tutorial && tutorial . relevanceScore > 0 )
33703370 . sort ( ( a , b ) => b . relevanceScore - a . relevanceScore )
33713371 . slice ( 0 , 5 ) ; // TOP 5 RESULTS
3372-
3372+ if ( query ) {
3373+ logSearchToGoogleForm ( query , categoryFilter , formatFilter , results . length ) ;
3374+ }
33733375 displayResults ( results , query ) ;
33743376 }
3375-
3377+
33763378 function displayResults ( results , query ) {
33773379 const resultsDiv = document . getElementById ( 'results' ) ;
33783380
@@ -3463,6 +3465,30 @@ <h2 style="color: #2c3e50;">Top ${results.length} Results for: "${query}"</h2>
34633465 document . getElementById ( 'searchInput' ) . value = element . textContent ;
34643466 searchTutorials ( ) ;
34653467 }
3468+ // Google Form Analytics Tracking
3469+ function logSearchToGoogleForm ( query , category , format , resultsCount ) {
3470+ // Your specific form configuration
3471+ const FORM_ID = '1FAIpQLSd8wDip8KCcyWioZUxtQFr3OXw2KKMjdMUAAyRpprA0r6_Omg' ;
3472+ const formURL = `https://docs.google.com/forms/d/e/${ FORM_ID } /formResponse` ;
3473+
3474+ // Your specific entry IDs from the URL you provided
3475+ const formData = new FormData ( ) ;
3476+ formData . append ( 'entry.1450901702' , query || 'empty' ) ; // Search Query
3477+ formData . append ( 'entry.1796583750' , category || 'all' ) ; // Category Filter
3478+ formData . append ( 'entry.708025292' , format || 'all' ) ; // Format Filter
3479+ formData . append ( 'entry.1349260545' , resultsCount . toString ( ) ) ; // Results Count
3480+ formData . append ( 'entry.1336855019' , new Date ( ) . toISOString ( ) ) ; // Timestamp
3481+
3482+ // Submit without waiting for response
3483+ fetch ( formURL , {
3484+ method : 'POST' ,
3485+ mode : 'no-cors' ,
3486+ body : formData
3487+ } ) . catch ( err => {
3488+ // This will show an error in console but the data still gets submitted
3489+ // This is normal behavior when using no-cors mode
3490+ } ) ;
3491+ }
34663492 </ script >
34673493</ body >
34683494</ html >
0 commit comments