Walkthrough: Create audiences based on time-on-site and time-on-page

  • Walkthrough: Create audiences based on time-on-site and time-on-page

Learn how to use the API and a timer trigger to create audiences based on engagement and time-on-site.

The time visitors spend on your website is a good indicator of their engagement. What's even more interesting, is the time they spend on specific pages or a page category. With Unless, you can create audiences based on time-on-site, such as "highly engaged readers", "engaged with product ABC for >3 minutes", "browsed product category XYZ for >5 minutes", and more. In this guide, we'll show you step-by-step how to set up the required timer trigger inside Google Tag Manager and how to connect it to Unless' API.

Timer Trigger & Google Tag Manager

To get started, you will need a Google Tag Manager account and permissions to edit your website’s GTM container.

Step 1: Access GTM & create the Timer trigger

In our case, we'll keep it simple and create a timer event that fires on all Blog pages after 30 seconds.

Unless API time-on-page-engagement-gtm-trigger First, as shown in the GIF above, add a new trigger. Choose Timer as the trigger type.

Unless API time-on-page-engagement-gtm-trigger4 Give the event a name (e.g. unless.timer.blog.pages). Enter the desired timer interval in milliseconds (e.g. for a 30 second timer, enter 30000) and set the timer limit to 1. Enable the timer trigger on all pages using the condition Page URL matches RegEx .* or enable it on a subset of target pages (e.g. page URL contains blog). Lastly, set the trigger to fire on All Timers and give it a name (e.g. Timer Trigger - 30 sec. - Blog Pages).

Step 2: Create an Unless Tag

To give you some background information, a tag is designed to send information from your site to a third party - in this case to Unless. Tags execute in response to events (e.g. unless.timer.blog.pages) and the timer trigger defines when the tag executes (in our case → >30 sec).

Unless API time-on-page-engagement-gtm-tag1 First set up a new Custom HTML tag.

Next, you'll need to add a small script to the tag that will send an event to Unless' API:


Unless API time-on-page-engagement-gtm-tag3 Lastly, give the tag a name (e.g. Unless - Txt Event - Blog Timer) and add the trigger (e.g. Timer Trigger - 30 sec. - Blog Pages) you created in Step 1.

Step 3: Submit to Live

You can now use GTM’s Preview & Debug mode to see your new tag in action. Unless API time-on-page-engagement-gtm-tag5 Once you are happy with the configuration, submit and publish a new GTM container version. From now, your website will throw a timer event and Unless' API will be able to pick it up.

Step 4: Switch to Unless & create Audience

For the next part, switch to your Unless account and create a new audience.

Unless API time-on-page-engagement-audience To pick up the event that you just created using GTM, simply set up an Audience based on Behavior → event → equals → unless.timer.blog.pages.

Step 5: Create your personalizations