How to redirect WordPress search query to Google CSE?
You can configure Google CSE to read the query variable (by default, it is q
).
Then, in your WordPress’s .htaccess file, add these 2 lines
RewriteCond %{QUERY_STRING} ^s=(.*)$
RewriteRule ^ https://www.google.com/cse/publicurl?cx=xyz&q=%1 [R,L]
Here, “https://www.google.com/cse/publicurl?cx=xyz” is your CSE’s public URL or the webpage that contains the Google CSE result (with Javascript provided by Google CSE in the page).
Could you help me setting-up Google Analytics using this approach?