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.
Click Admin, and navigate to the view in which you want to set up Site Search. In the View column, click View Settings. Under Site Search Settings, set Site Search Tracking to ON. In the Query Parameter field, enter the word or words that designate internal query parameters, such as term,search,query,keywords.
When you have multiple websites to track, you can use a single account to add multiple sites in Google Analytics, which can be done in two ways. You can either add all your sites under a single Analytics account as different properties or add a unique Analytics account ID to each individual site.
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With