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.
To get started, you will need a Google Tag Manager account and permissions to edit your website’s GTM container.
In our case, we'll keep it simple and create a timer event that fires on all Blog pages after 30 seconds.
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).
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).
Next, you'll need to add a small script to the tag that will send an event to Unless' API:
You can now use GTM’s Preview & Debug mode to see your new tag in action. 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.
For the next part, switch to your Unless account and create a new audience.