Sam Jefferies
Sam Jefferies

Reputation: 594

Fire event on clicking anywhere within a div containing a particular class? (Via Google Tag Manager)

I'm trying to fire an event when a user clicks on a related post.

These are held within a parent div that has the class of: related-post-click

Example: See the picture of the kid in a hoodie at the bottom of: https://www.nominet.uk/if-i-was-back-at-school-now-i-would-definitely-study-technology/

My attempt is:

Click Classes | matches CSS selector | .related-post-click *

The HTML is as follows:

enter image description here

I just can't get it to work!

Upvotes: 0

Views: 531

Answers (1)

kgrg
kgrg

Reputation: 1633

There are two things to consider here.

  • The "matches CSS selector" operator can be used with the "Click Element" variable, regardless of the selector type (class, id, etc).
  • If the parent element itself can receive clicks based on the actual content and layout, you might want to include the parent element and all its children in the selection, so your selector should be in this case: .related-post-click, .related-post-click *

Upvotes: 1

Related Questions