So there's this nifty _trackPageview() api method on a tracker object, but is there a corresponding method that can be used to manually track a search? In other words, _trackPageview()
reports to GA that a user hit a page. I want something like _trackSearch("terms")
that would report to GA that a user searched for something.
views:
78answers:
2
A:
Though not exactly what I was looking for, it seems that one can generate virtual page views to track search results programatically.
Suppose that you've set up a Site Search parameter called "q", so that when a URI is tracked that contains q=these+are+some+terms
, GA will mark it as a search hit. One can use the _trackPageview()
method to generate virtual search hits like so:
pageTracker._trackPageview('/custom/search?q=These+are+some+terms')
Mike Caron
2009-12-30 23:27:54
A:
I pass search parameters by GET, so the URL for a search on "TEST" is
http://www.example.com/search?q=TEST
Selecting Content
-> Site Search
from my analytics account gives me a list of all keywords searched.
To learn more, check the documentation, especially the How do I set up Site Search for my profile? page.
Pete
2009-12-30 23:28:28
I wanted to avoid using GET. I managed to use the onsubmit attribute of the form to fire the javascript I mentioned in my answer.
Mike Caron
2009-12-31 03:09:37
Maybe you could make your question more specific then!
Pete
2009-12-31 15:40:22