Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking ajax-based search with Google Analytics

We have a search box that displays results on Google Map embedded into the page. We use ajax async calls to the server to perform the search and then display the results back on the map without any redirect or change in the page url.

Is it possible to use Google Analytics' Site Search to track this? What would be the set up for that? Or is this not something that was meant to be tracked with Site Search feature at all?

like image 995
Alexandra Avatar asked Mar 15 '13 15:03

Alexandra


2 Answers

Just a syntax update for Google Universal Analytics for the already great answer:

ga('send', 'pageview', '/mysite/?q=searchterm');
like image 172
Simon Ferndriger Avatar answered Sep 27 '22 18:09

Simon Ferndriger


Lodge a virtual pageview (a trackPageview-call with a second parameter) in your ajax request with your search parameter as a get parameter in the virtual url (the name for the search parameter must be configured in the GA backend).

...(on ajax success)..:
_gaq.push(['_trackPageview','mysite/?q=searchterm']);
like image 31
Eike Pierstorff Avatar answered Sep 27 '22 16:09

Eike Pierstorff