Can a specific route include specific js - Piwik tracking
-
@pichalite and @psychobunny Yes, yes. Now it is working better. Thank you.
How do I see what other variables are available specifically related to the search. Really my code bit needs to report to Piwik the search term and hopefully the result count.
_paq.push(['trackSiteSearch', searchTerm,, resultCount]);
Are those two variables available to me?
Thank you.
-
@rod add a
console.log(data);
to your code and you can see what's in the data object in your browser consolethe data object has
url
andtpl
if there is a search query, then the
url
will look like this
search/welcome?in=titlesposts&sortBy=timestamp&sortDirection=desc&showAs=posts
so the part between
search/
and the?
is the search term.welcome
in this case. -
Looking at the source for NodeBB on github in
search.js
I see this:if (data.searchIn === 'posts' || data.searchIn === 'titlesposts') { search.searchQuery('post', data.query, results.searchCids, results.searchUids, next);
Is the
data.query
object available to me? -
@pichalite And voila!
_paq.push(['trackSiteSearch', ajaxify.data.search_query,, ajaxify.data.matchCount]);
Piwik now gets the search query and the number of results.
And, yup, there it was on line 25 staring me in the face:
result.search_query = validator.escape(data.query);
Thanks for helping an 'old guy out.
-
If you are interested, it would be great if you wrote a guide to set up Piwik for NodeBB
I'm thinking of adding a "tutorials" category for stuff like this
-
@psychobunny Considering how helpful this community has been it would be my pleasure to contribute back in this tiny way. I will take ownership of writing up a document on how to make Piwik and NodeBB work in harmony.
-
Awesome I went ahead and created a tutorials category, hope to see that full of guides in the near future