ga4-semantic-automator live demo

One initGA4() call captures every click on interactive elements across the DOM. Click anything below and watch the structured event hit the data layer — no per-element tracking code. (Real GA4 hits are disabled here; the data layer is intercepted locally.)

Section #hero — plain buttons

Clicks on the icon/text inside a button resolve to the nearest button ancestor. Note the element_id, element_class and structural_container: "section#hero" in the log.

Section #pricing — declarative overrides

Toggle FAQ (role="button")

data-ga-event renames the event; data-ga-label overrides element_text and sets element_label; role="button" is tracked via aria-label.

Nav — anchors & outbound links

Anchors capture destination and set is_outbound: true when the host differs from the current page.

Cookie banner — data-ga-ignore

The whole section is marked data-ga-ignore. Clicking these buttons produces no log entry.

Data layer log

Waiting for interactions…