Tracking text entered into a text box


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):

function(e) {
try {
var piwikTracker = Piwik.getTracker(pkBaseURL
+ “piwik.php”, 2);
var searchTerm = $("#searchBox").val();
piwikTracker.setCustomVariable(1, “search term”,
searchTerm, scope = “visit”);
} 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