How/where to integrate the javaScript Internal search tracking

Hi guys, I’ve been looking around for an answer to my question for a while, but can’t seem to find it.

I want to track the internal site searches, but the URL-Parameter is encoded, so I can’t do it via the GET-parameter. Thus I looked into other options (JavaScript and API). My developers say that the JavaScript option could work (see screenshot)

However, I have never worked with Matomo before and I have absolutely no idea exactly where to install this code (in the header, the body etc.). Any advice on this?

Thanks!

Hi,

This depends on how your website is built.

If the search is done browser-side (so a Javascript request initializes the search) then you simply call this code whenever you do the search.

When the search is a normal page, then the easiest way is to do it in the normal tracking code and instead of trackPageView you call the trackSiteSearch code.