CSS in GTM

Tagged in:  Content

GTM tagging can be super useful if you know what you're doing. And this guy Simo Ahava really does. This guide, is a super useful reference and instructional piece.

The article is a guide to using the “Matches CSS Selector” Operator In GTM Triggers. This really helps to create events for buttons and things that were built by really shitty developers on really shitty CMSs. Because we are analytics and metrics people, we often have to retro-fit clever measurement to dumbly built pages. This guide really helped us clarify some stuff, so we thought we’d post about it. And the best part about it? This table that we use for reference often:

SELECTOR DESCRIPTION
.thisclass Matches if element has class “thisclass”
.thisclass.thatclass Matches if element has class “thisclass” and class “thatclass”
#thisid Matches if element has ID “thisid”
#main .navlink Matches if element has class “navlink” and is a descendant of an element with the ID “main”
div#main > .navlink Matches if element has class “navlink” and is the direct child of a DIV element with the ID “main”
:checked Matches if element is checked (radio button or checkbox)
[data-title*=”chairman mao”] Matches if element has attribute “data-title” with the string “chairman mao” somewhere in its value
a[href$=”.pdf”] Matches if element is a link (A) with a HREF attribute that ends with “.pdf”
.contactmail:only-child Matches if element has class “contactmail” and is the only child of its parent


View the article



Posted on July 28 2016 by Stephen van der Heijden
Stephen is the founder of UNO Digital. He loves digital products, digital people, and people in the digital world.



Next: SoDA digital marketing outlook  Previous: Sprout Social

Contact Us

What are you sinking about?