If you already have a Google Analytics account, you can configure Analytics Site Search reports from within Programmable Search Engine.
To enable Google Analytics Site Search, you must add the Google Analytics tracking code to your site.
Configure Google Analytics Site Search reports:
- On the Programmable Search Engine home page, under Edit search engine, select the search engine you want.
- Click Statistics, and then click the Google Analytics tab.
- Select the Google Analytics profile you would like to use from the drop-down menu.
- In the Query parameters box, type the query parameters you want to use. Please enter only the word or words that designate an internal query parameter such as "term,search,query". Sometimes the word is just a letter, such as "s" or "q". You can provide up to five parameters, each separated by a comma.
- (Optional) If your search engine includes refinements, type the category parameter in the Category parameters box.
- Click OK.
Your page should now contain both the Programmable Search Engine snippet and the Google Analytics tracking code, like this:
<!DOCTYPE html> <html> <head> <title>Example</title> </head> <body> <!-- Paste your search engine code snippet (for search results) here. --> <!-- The following is your Google Analytics setup code. --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-12345678-1'); </script> </body> </html>
You’re done. You can now see Site Search reports in Google Analytics. Note that it may take several hours before data is available for viewing.