Tracking text entered into a text box


#1

Apologies if this is a dumb question - I’ve checked the FAQ and done some searching but nothing seems to come up.

I have a search box on my site, from which I’d like to track the terms entered. I’d like to do this every time the search button is clicked, regardless of which page it’s on and which visitor it is.

I thought a custom variable would be the way to go, but on setting this up it will only register the first search, regardless of the scope specified.

Am I missing something, or is my understanding of Piwik incorrect?

For info, the javascript track I’m using to capture the search term (using JQuery):

$("#companySearchBtn").click(
function(e) {
try {
var piwikTracker = Piwik.getTracker(pkBaseURL
+ “piwik.php”, 2);
var searchTerm = $("#searchBox").val();
piwikTracker.setCustomVariable(1, “search term”,
searchTerm, scope = “visit”);
//piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) {
alert("error on search button: " + err);
}
});


(Matthieu Aubry) #2

You probably should use the Site Search plugin? GitHub - BeezyT/piwik-sitesearch: SiteSearch Plugin for Piwik