Analytics GTM

Using GTM to fire Tags in Legacy Pages but not in WordPress

Issue: Make the GTM recognize if you are on a wordpress page and if you are not then fire a tag


Step #1: Create a DOM Variable in GTM to store the information of whether a page is built with WordPress or not.

I have identified that the pages in my wordpress site all have a class in Elementor named “wp-page”. So I use CSS Selector and get it with [data-elementor-type=”wp-page”].


Step #2 Build a DOM Ready Trigger and use as trigger the above DOM variable.

This triggers works as the lever of the whole process. If the DOM – Element WordPress is not “null” (meaning that the page I currently am is WordPress), then don’t fire.

If the page is legacy then the DOM – Element WordPress is “null” meaning that the trigger should fire.

Step #3 Attach the trigger to a tag