Setting up timer triggers in Google Tag Manager (GTM) is a powerful way to automate the firing of tags after a set amount of time has passed. This is especially useful for tracking user engagement, such as monitoring the time users spend on a page or triggering events after a specific duration.
Here’s how you can set up timer triggers in Google Tag Manager:
Step 1: Create a New Timer Trigger
- Log in to Google Tag Manager and open the container you want to configure.
- In the left-hand menu, click on Triggers.
- Click the New button to create a new trigger.
- Give your trigger a descriptive name, such as Timer Trigger – 30 seconds.
- Click on Trigger Configuration, then select Timer from the list of trigger types.
Step 2: Configure the Timer Trigger
In the Timer Trigger Configuration, you’ll set the parameters that determine how the trigger behaves. The options include:
- Interval (in milliseconds):
- This specifies how often the trigger should check if the conditions are met. For example, if you want to fire the trigger after 30 seconds, you need to set the interval to
30000
(because 1 second = 1000 milliseconds, and 30 seconds = 30,000 milliseconds). - Example: To fire the trigger every 30 seconds, enter
30000
.
- This specifies how often the trigger should check if the conditions are met. For example, if you want to fire the trigger after 30 seconds, you need to set the interval to
- Limit (in number of times):
- This defines how many times the timer will fire. If you want the trigger to fire only once (after the first 30 seconds), set the limit to
1
. - Example: Set to
1
if you want it to fire just once after the specified interval.
- This defines how many times the timer will fire. If you want the trigger to fire only once (after the first 30 seconds), set the limit to
- Page URL Condition (optional):
- You can also set the timer to fire on specific pages. If you only want the timer to fire on particular pages, set a Page URL condition (e.g., the trigger only fires on certain pages of your site).
- For example, set the trigger to fire only on
/product-page
by choosing Page URL and setting the condition to contains/product-page
.
- Additional Conditions (optional):
- If necessary, you can add other conditions to refine when the timer trigger fires, such as checking for certain DOM elements or events.
Step 3: Choose the Tag to Fire with the Timer Trigger
After configuring the timer trigger, you will need to associate it with a tag. This could be any tag you wish to fire after the specified interval. Here are the steps to associate your timer trigger with a tag:
- Go to Tags in the left-hand menu and click New to create a new tag.
- Choose the type of tag you want to set up, such as a Google Analytics tag, a Custom HTML tag, or any other tag that fits your needs.
- Configure the tag as you normally would (e.g., set up a Google Analytics event tag).
- Under Triggering, select the timer trigger you created earlier. This ensures that the tag will fire when the timer reaches the specified interval.
Step 4: Test the Timer Trigger and Tag
Before publishing your changes, it’s essential to test if everything is working correctly:
- Click the Preview button in Google Tag Manager to enter the preview mode.
- Open your website in a new tab (the preview mode should automatically open a debug window).
- Navigate to the page where your timer trigger is set to fire.
- Wait for the specified interval (e.g., 30 seconds) and check the Preview Mode debug console to see if the tag fired as expected.
- If the tag does not fire, make sure you’ve set the correct interval and conditions.
- If necessary, adjust the interval or page conditions.
Step 5: Publish the Container
Once you’ve tested and confirmed that the timer trigger and tag are firing correctly, you can publish your changes:
- After testing, go back to Google Tag Manager.
- Click Submit to submit your container changes.
- Provide a version name (e.g., “Timer Trigger Setup”).
- Click Publish to make the changes live.
Use Cases for Timer Triggers
Timer triggers are useful in various situations, such as:
- Engagement Tracking: Track how long users spend on a page before performing an action, such as submitting a form or interacting with a specific element.
- Event Tracking: Fire events after a certain amount of time to measure engagement, such as tracking how many users stayed on the page for more than 30 seconds.
- Page Interactions: Trigger events if a user has been on a page for a specific duration without interacting with elements (such as scrolling or clicking), which might indicate that the user is passive or disengaged.
Advanced Configuration of Timer Triggers
- Firing Multiple Times: If you want the timer to trigger at multiple intervals (e.g., every 30 seconds), you can set the interval to a lower value (e.g., 10000 for 10 seconds) and set the limit to fire multiple times. This can be useful for tracking long sessions.
- Custom JavaScript for Timer Interactions: If the built-in timer trigger doesn’t meet your needs, you can use Custom HTML tags with JavaScript to trigger events based on complex interactions or custom timing functions.
This script can be placed in a Custom HTML tag that pushes an event to the dataLayer after 30 seconds, triggering an event for further tracking.
Best Practices
- Be mindful of performance: Too many timers on your site can affect page load speed or performance, so use them sparingly.
- Adjust timing carefully: Make sure your timing is reasonable. For example, setting a timer to fire too soon (e.g., 5 seconds) might not give users enough time to engage with the page, while too long of a delay might make the trigger irrelevant.
- Use for meaningful actions: Set up timers for actions that provide insights into user behavior or engagement, such as tracking if users are staying on your content long enough to interact with it.
Conclusion
Timer triggers in Google Tag Manager are a valuable tool for tracking user interactions based on time spent on a page. By following the steps outlined above, you can create timer triggers to measure engagement, monitor content consumption, and optimize your marketing strategies. Just remember to test your setup thoroughly before going live to ensure accurate tracking and performance.