How to create a tag firing priority in Google Tag Manager

Author:

Creating a tag firing priority in Google Tag Manager (GTM) helps ensure that your tags load in a specific order, which can be crucial for data accuracy, tag dependencies, and page speed optimization. Below, I’ll explain the key concepts and steps to establish a tag firing priority effectively in GTM, along with some best practices.

1. Understanding Tag Firing in GTM

In GTM, tags are snippets of JavaScript or HTML code (like Google Analytics, Google Ads, or third-party pixels) that you add to your website to track various interactions. Tags are configured to fire (or run) based on specified triggers, which are conditions that define when a tag should execute. However, there are situations where the firing order of tags is essential for accurate data collection, for example:

  • Ensuring a main tag (like Google Analytics) fires before associated tags (e.g., Google Ads conversion tracking).
  • Controlling when a tag fires to avoid potential data conflicts.
  • Prioritizing tags based on page speed considerations.

2. Establishing Tag Firing Priority in GTM

By default, GTM attempts to fire tags as soon as possible based on their respective triggers. You can create a tag firing priority to control this process using tag sequencing and priority settings. Here’s how:

Step 1: Using Tag Sequencing

Tag sequencing allows you to specify that certain tags should fire before or after a particular tag. This can be especially useful for setting up dependencies, like ensuring your tracking tag fires before a remarketing tag that relies on its data.

  1. Go to Tag Configuration:
    • In GTM, navigate to your tag list and select the tag you want to configure. Click on it to open the configuration settings.
  2. Enable Tag Sequencing:
    • In the tag’s configuration options, scroll down to the Advanced Settings section and select Tag Sequencing.
  3. Choose a “Setup Tag”:
    • Enable Fire a setup tag before main tag fires and select the tag that you want to fire before your main tag. This tag will act as a prerequisite.
  4. Choose a “Cleanup Tag” (Optional):
    • If you need another tag to fire after your main tag, you can select Fire a cleanup tag after main tag fires and specify the tag to fire post-execution. This is particularly useful for any tags that need to clean up or end certain actions after the main tag completes.
  5. Configure “Blocking Trigger” (Optional):
    • You may also specify a blocking trigger that stops the tag if certain conditions are met. This is useful to avoid triggering certain tags in unintended scenarios.

By setting up tag sequencing, you can ensure that a particular tag fires either before or after the tag in focus, enabling effective priority management.

Step 2: Adjusting Tag Priority

Tag priority is another way to control the order of tag firing. Each tag can be assigned a priority number; tags with higher priority values will fire before those with lower values.

  1. Set Tag Priority:
    • In your tag’s configuration under Advanced Settings, locate the Tag Firing Priority option.
  2. Choose a Priority Level:
    • Enter a number for the priority. GTM doesn’t have a set range, but higher numbers indicate higher priority. For example, assigning a priority of “100” will ensure that this tag fires before a tag with a priority of “10”.
  3. Apply Tag Firing Priority Across Tags:
    • Adjust the priority levels on other tags based on how you want them to fire relative to each other. Tags with identical priorities will fire simultaneously.

3. Common Scenarios for Tag Firing Priority

Here are some scenarios in which setting tag firing priority and sequencing are beneficial:

  • Google Analytics and Remarketing Tags: Fire the Google Analytics tag before any remarketing tags that rely on analytics data.
  • Consent Management: If using a consent management platform (CMP), ensure that consent tags fire first to respect user privacy before triggering other tags.
  • Error Prevention in Conversion Tracking: For conversion tracking tags, ensure setup tags (like Google Analytics or a data layer variable initialization) fire beforehand.

4. Testing Tag Firing Priority

Testing is crucial to confirm that your tags fire in the intended order and work without interference.

  1. Preview Mode:
    • In GTM, use the Preview mode to test your container. This tool enables you to observe the order in which tags are firing on your site in real time.
  2. Check the Debug Pane:
    • Once in Preview mode, navigate to your website, and in the GTM Debug pane, you’ll see the sequence in which tags are firing. Tags should display in the order specified by your priority settings and sequencing.
  3. Verify Using Browser Console:
    • Open the browser console (usually accessible with F12 on most browsers) and look for any logs or errors associated with tags. This step is helpful for identifying any conflicts or potential delays in tag firing.
  4. Adjust and Retest:
    • If the tags don’t fire in the expected order, return to the tag configuration, adjust the sequencing or priority, and test again. Iteration may be necessary to ensure tags fire smoothly.

5. Best Practices for Tag Firing Priority in GTM

To maintain an organized and effective tagging setup, follow these best practices:

  • Limit the Number of High-Priority Tags: Too many high-priority tags can slow down page loading. Use tag priority settings sparingly to maintain performance.
  • Avoid Conflicting Priorities: Be cautious with sequencing when two tags are set to high priority but are dependent on each other. This can lead to race conditions where tags fail to fire properly.
  • Use Setup and Cleanup Tags Judiciously: Only apply setup and cleanup tags when there’s a clear dependency. Adding unnecessary tags can increase complexity and slow down debugging.
  • Document Tag Firing Priority: Maintain a record of tag firing priorities and sequences. This documentation helps during audits and when other team members need to understand or modify GTM configurations.
  • Check Dependencies Regularly: Tag dependencies may change as you add or remove tags. Regularly review and update your firing priorities as needed.

6. Troubleshooting Common Issues

Sometimes, even with careful configuration, tags might not fire as expected. Here are common issues and solutions:

  • Missing Setup Tags: If setup tags aren’t firing, check that they are not blocked by other triggers.
  • Conflicting Priorities: If multiple tags with the same priority level are causing issues, adjust the priority numbers to clarify the intended order.
  • Page Load Speed: High-priority tags can slow down page load if not carefully managed. Ensure non-critical tags have lower priorities to improve load time.
  • Consent Management Issues: For sites with a CMP, verify that consent-related tags fire before data-collection tags. GTM may require additional configurations if the CMP isn’t triggering tags as expected.

Conclusion

Implementing a tag firing priority in Google Tag Manager requires careful setup of tag sequencing and priority settings. By leveraging these tools effectively, you can ensure accurate data collection, maintain tag dependencies, and optimize page performance. The best approach is to start with a simple configuration, gradually build in complexity as needed, and test thoroughly to avoid conflicts or delays. With a well-organized firing priority, GTM becomes a powerful tool for managing and orchestrating your website’s tracking setup efficiently.