I am trying to run a bit of an A/B test and would like to look at GA4 traffic that visits certain pages that meet certain criteria. Is there a way of flagging GA4 based on an id/class that appears on the page, or do I need to send it a ga() signal. If so, what's the signal?

I just want to clarity, this isn't exactly an A/B test per se, but rather I would like to look at all pages that have a certain id/class that appears on the page. They don't all fall within a particular folder or section on the site. I do have a way of identifying these pages and passing in a ga('event', ...) signal, if that helps.

I'm realizing now I can achieve what I want with GA4 events.

In Google Analytics 4 (GA4), an event is a user interaction or occurrence on a website or app, such as a page view, button click, scroll, or purchase

Looking at only traffic that has an occurrence on a webpage is exactly what I'm looking for.

Also, not ga(). I meant gtag(). I think ga() was the previous method before GA4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.