On really long essays or eBooks I would often use the in built browser search (ctrl + f) to skip between bits of content and find what I am looking for. Likewise with API docs.

When I wouldn’t use it is during short to medium length blog posts, unless the information has been laid out in a poor manner and I need to try and find the one nugget of information that is useful to me.

I have come to the conclusion that if someone is having do a browser search then I have probably failed at organising my post.

This is why I made a small (473B minified) script that will log an event in Google Analytics if someone has decided they need to use a browser search.

You can check out the code at the Ctrl+F Events github repo. Feel free to submit issues or create pull requests with changes you would like to see.

What I initially wanted to track

What I would have loved to track is the words people were searching for. Unfortunately there is currently no way for the browser to let you know this information.

I could hijack the key press and cobble something together to do searching myself, but that seems incredibly fraught with danger and I absolutely hate standard browser functionality being messed with.

What I ended up tracking

What I ended up tracking was the event itself, so when someone triggers the browser search an event gets created in Google Analytics – I check for both the new and old Google Analytics code and make the appropriate call.

Technical Challenges

The script is incredibly straight forward, there is no real magic. The biggest technical challenge was making sure all browsers were covered.

I still need to test this more, but it looks like the ctrl button gives off a universal key code, the cmd button (on the Mac keyboard) gives different codes depending on the browser. I wrote up a quick post on the different Command Key Codes.

Why not read some more of our Google Analytics posts?