DE

EN

Blog Post

Web analytics

Nadine

Wolff

published on:

Average Time Spent on Page – Track User Engagement with Google Tag Manager

Table of Contents

No table of contents available

Google Analytics is one of the most popular tools available for webmasters and online marketing managers looking to analyze user behavior on their websites. Once the tracking code is embedded into the source code of each page, user data is sent directly to Google Analytics. Depending on your tracking ID, the data flows into your Google Analytics account, allowing you to easily analyze how visitors interact with your site. For instance, the predefined standard reports offer interesting insights through metrics like "Avg. Time on Page."

If you'd like to track additional elements beyond standard Google Analytics tracking—such as button clicks or PDF downloads—we recommend setting up the Universal Analytics code via Google Tag Manager. Google Tag Manager is a handy tool that lets you create and manage user-friendly tags without needing extensive programming skills. The collected data is then sent to your Google Analytics account using your tracking ID (UA number).

Previous articles on Google Tag Manager:

Find out how long visitors stay on your pages

A standard metric in Google Analytics reports is "Avg. Time on Page." It shows how many seconds or minutes users spend on individual pages. However, there's a catch with this metric: Google Analytics can only accurately determine the time spent if the visitor navigates to at least one other page. If they don't, Google Analytics simply logs the last page as an exit or bounce if only a single page was visited during the session. Here's how it works: When a user opens a page, a pageview is sent to Google Analytics and recorded in the reports. Time tracking begins at that moment. If the user then visits a new site on a different domain, Google Analytics won't notice because no tag is fired. Instead, the timer keeps running until the session officially expires after 30 minutes (unless configured otherwise).

This is where Google Tag Manager comes to the rescue: with custom HTML code, you can track the true time a user spends on a page. This is especially useful for blog operators.

Imagine a user searches for a specific topic, finds your article via Google, reads the entire post, and then leaves your site. That user would be counted as a bounce and would increase your bounce rate. Their time on the page cannot be accurately recorded, so it gets set to 0:00 minutes. The same goes for any landing page. This dramatically skews your data—even though the visitor did exactly what you hoped for: engaging deeply with your content.

How to measure user time on page with Google Tag Manager

In this article, we assume you are already using Tag Manager to implement Universal Analytics tracking. If not, we recommend starting with the basic setup of Tag Manager first.

To measure the true visit duration for every single pageview, you will need to create two tags, two data layer variables, and one trigger in your container workspace.

Let's start by creating two data layer variables. Go to Variables in the left navigation menu and add two new data layer variables: one for the event label and one for the event value. The new custom variables should look like this:

01 - Datenschichtvariable - Ereignislabel

Figure 1: Setting up the Data Layer Variable - Event Label



02 -Datenschichtvariable - Ereigniswert

Figure 2: Setting up the Data Layer Variable - Event Value



Both variables are crucial so that data from the function in the upcoming HTML script is correctly recognized and the events can be passed along to Analytics.

To create the first tag, click NEW on the left side of your workspace and select the Custom HTML Tag.

03-Benutzerdefiniertes HTML Tag einfügen

Figure 3: Creating a Custom HTML Tag



Custom tags allow you to manage tags that aren't natively supported out of the box in Tag Manager.

The function above is written to fire a "Riveted" event every 10 seconds, recording the number of seconds spent on the page. The event only fires if the user's browser window is active and they perform one of the following actions:

  • Mouse movement

  • Mouse scrolling

  • Mouse clicks

  • Keystrokes on the keyboard

If the user switches to a second tab or works in another program, tracking stops firing after 60 seconds. If they return to the page later without refreshing, the event will resume.

Set the trigger for this tag to "DOM Ready." This means the tag will fire once the browser has read the source code from top to bottom. Keep in mind, this is not the same as the page being completely loaded and rendered for the user.

The completed tag should look like this:

04 -Benutzerdefiniertes Tag

Figure 4: Custom Tag in Google Tag Manager



The second tag to create is a Universal Analytics tag of type Event. You should configure the settings as shown in the screenshot below.

05 -Einrichtung des Analytics-Tags

Figure 5: Setting up the Universal Analytics Tag



Make sure not to forget IP anonymization, and set the "Non-Interaction Hit" field to "True." This ensures that the event won't impact your bounce rate, as it won't be counted as an active interaction with the page. In other words, if a user lands on one of your pages, spends plenty of time reading the content with the tab active, but doesn't visit a second page, the session will still count as a bounce, but their actual time on the page will be captured via event tracking.

Set this tag's trigger to fire on a custom event named "Riveted." This event name is defined in your Custom HTML tag. Every 10 seconds—as long as the user remains active on the page—the "Riveted" event fires, prompting this second tag to send the values over to Google Analytics.

06 - Trigger für Analytics-Tag

Figure 6: Trigger settings for the Universal Analytics Tag



Time on page as event tracking in Google Analytics

Once you've created and published both tags, the variables, and the triggers, you'll be able to view your users' time on page directly in Google Analytics.

To find it, navigate in the Analytics interface to Behavior - Events - Top Events on the left menu.

For the Event Category, select "Engagement" (or whatever category name you assigned in your tag).

In the next view, Event Action, click on "Time on Page," and you will see the users' dwell time in seconds displayed as the Event Label.

Add "Page" as a secondary dimension to see the time spent on specific pages.

07 -Navigation zu wichtigsten Ereignissen bei Google Analytics

Figure 7: Navigating to Events in Google Analytics



How can we help?

Do you have any questions about this article or need assistance with web analytics? We'd love to hear from you—feel free to reach out via our contact form or give us a call.

Nadine

Wolff

As a long-time expert in SEO (and web analytics), Nadine Wolff has been working with internetwarriors since 2015. She leads the SEO & Web Analytics team and is passionate about all the (sometimes quirky) innovations from Google and the other major search engines. In the SEO field, Nadine has published articles in Website Boosting and looks forward to professional workshops and sustainable organic exchanges.

Address

Bülowstraße 66

Aufgang D3

10783 Berlin

Legal Information

Newsletter

Address

Bülowstraße 66

Aufgang D3

10783 Berlin

Legal Information

Newsletter

Address

Bülowstraße 66

Aufgang D3

10783 Berlin

Legal Information

Newsletter