Google Tag Manager: How to Track Shortcuts

August 13, 2018 - Written by

Last week my fridge broke. And what’s with the blog post?

Everything arises from the specs when looking for the new appliance, such as “No frost”, “Reversible doors”, etc.

While browsing the main technology and electronic e-commerce websites and starting digging around, I tried to find the specs without looking through the entire spec sheet – frequently hidden inside tabs. So I compulsively started to use the shortcut CMD (Ctrl) + F.

At this point I asked myself: is it possible to track the different shortcuts via Google Tag Manager and Google Analytics? The answer is: of course, yes it is!

Why track the shortcuts?

Tracking the shortcuts allows to understand how many users (few? a lot?) engage with the site without using a mouse and specifically I’m interested in those who use the shortcuts search into pages CMD (Ctrl) + F and the reload pages CMD +R.

By using shortcuts they are searching for something inside the website. In which page they perform such a deep searching action? Are pages that present technical contents? Are very long articles? And so on.

Unfortunately it is not possible to identify the keyword the user is typing in the browser search bar, but we can match it with the text highlight selected with the mouse.

While conducting usability tests at tour headquarters, I noticed that some users, once performed their search, highlighted the keyword or part of the text near the keyword itself with the mouse.

We know that a strong correlation between the tracking of Ctrl+F and the text highlight is a kind of stretch, however we can get a sense of the searches performed by the users into the website.

Google Tag Manager: tracking key combinations

In order to track the key combinations performed by users, you have to develop a Custom HTML tag and then a Universal Analytics tag.

Custom HTML Tag

The tag must be fired in each page and includes the tracking for the key combinations Ctrl+F, Ctrl+S, Ctrl+G and Ctrl+R.

Ctrl+R is so useful to understand if a user reloaded or not the page while browsing. You can track each key combinations by replacing the values inside the cases.

Universal Analytics Tag

Now you only need to set a Universal Analytics Event so that you can collect the values you tracked with the tag above. The tag will include in the Category the variable “Keyboard Click” while in Action you need to pass the value of the dataLayer variable “Key Pressed”.

The trigger will be “clickKeyboard”, to be created inside the dataLayer Event.

Highlighted Keyword

As I said above, understanding the text highlighted by users with the mouse can be useful to have some hints about the keyword typed while searching, or about which part of the contents they dwell on more. To grab this information you have to create a Custom Javascript variable which returns the value of the highlighted text:

The new variable can be used both as an Event action or label and as a trigger to fire a Universal Analytics tag that includes the information about the highlighted text.

A low percentage of users typing shortcuts is expected, but the tracking provides the opportunity to better understand our users’ habits, mostly with regard to page reload and site search.


Leave a Reply

Your email address will not be published. Required fields are marked *

  • Analytics Boosters

    Vicolo Buranelli, 2
    31100 Treviso

  • Analytics Boosters
    United Kingdom

    41 Devonshire Street
    W1G 7AJ
    United Kingdom

  • Analytics Boosters
    United States

    80 S.W. 8th Street
    33130 - Miami
    United States of America


Contact us