Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

Grouping Law Firm Pages by Practice Area in GA4 Reports

If you build or maintain sites for criminal defense firms, sooner or later a partner asks a question GA4 cannot answer out of the box: how are the DUI pages doing compared with the drug charge pages? A defense site might

If you build or maintain sites for criminal defense firms, sooner or later a partner asks a question GA4 cannot answer out of the box: how are the DUI pages doing compared with the drug charge pages? A defense site might have forty URLs about DUI alone, spread across charge pages, courthouse pages, blog posts and FAQs. The default Pages and screens report lists them one by one, which is fine for spotting a single winner and useless for comparing practice areas.

GA4 has a built-in answer that many developers skip: the content group. You set one value per page, and GA4 records it with every event on that page. After that, any report that offers the Content group dimension can roll up traffic, engagement and conversions by practice area. This post covers how to plan the groups, how to send them and the mistakes that make the data unreliable.

Plan the groups before writing any code

Decide on a short, fixed list of groups that match how the firm thinks about its practice. For a typical defense site that might be:

  • dui
  • drug-charges
  • domestic-violence
  • theft
  • violent-crimes
  • sex-crimes
  • general (homepage, about, contact, attorney bios)

Keep the list small. Ten groups are readable in a report. Forty are not. Agree on the exact strings with whoever reads the reports, write them down and treat them as a controlled list. "DUI", "dui" and "Dui" will show up as three separate rows.

Decide how to handle pages that span groups, such as a post about a DUI with drug charges. Pick the primary topic and move on. A page gets one content group, and trying to be precise about mixed topics creates more noise than insight.

Store the group with the page

The cleanest source for the value is the page itself, set in the CMS. In WordPress, that might be a custom field or a mapping from the post's primary category. In a headless setup, add a required field to the page model. In a static site, put it in front matter.

Avoid deriving groups from URLs with regular expressions in the tag. It works until someone publishes a page outside the expected folder, and then that page silently falls into "(not set)". A field on the page is visible to editors and easier to audit.

Sending the content group

With gtag.js, set the value in the config call before the page view fires. Render the value server-side into the template:

<script>
  gtag('config', 'G-XXXXXXXXXX', {
    content_group: 'dui'
  });
</script>

With Google Tag Manager, push the value into the data layer above the container snippet, read it with a Data Layer Variable, and add content_group as a configuration parameter on the Google tag. Either way, check in DebugView that page_view events carry the parameter before you trust any report.

If the site is a single-page app with client-side routing, update the value on each route change and make sure the virtual page view fires after it. Otherwise the first page's group sticks to every page that follows.

Reading the reports

Once data flows, open the Pages and screens report and switch the primary dimension to Content group. You will see views, users, engagement and key events per group. For call and form tracking, make sure those actions are marked as key events so they appear alongside the traffic numbers.

For deeper work, build an Exploration with Content group as a row dimension and your call and form key events as values. That answers the partner's question directly: which practice areas bring in contacts, and how many pages it takes to get there. Pair it with Search Console query data to see which groups have demand but weak pages. There is a walkthrough on using Search Console queries to choose which charge page to fix that fits well with this.

Mistakes that break the data

A few problems come up repeatedly on law firm sites:

  1. Content groups are not retroactive. Reports only show groups from the day you start sending them, so note the launch date.
  2. Templates without the field send nothing, and those pages show as "(not set)". Check that row weekly for the first month.
  3. Renaming a group splits its history. If you must rename, do it at the start of a month and note it.
  4. Landing pages and conversion pages often belong to different groups. A visitor who reads a DUI page and then calls from the contact page credits "general" for the key event unless you report on the landing page's group too.

Keep reporting on outcomes aggregate. Do not attach anything about a caller's situation to analytics events, since intake details can be confidential.

More on analytics and search data for law firm sites is collected in our legal marketing analytics and search data library.

Questions developers ask about GA4 content groups

Can a page belong to more than one content group?

No. The parameter holds one value per page. If you need a second way to slice pages, such as page type, register a separate event-scoped custom dimension.

Do content groups count against custom dimension limits?

Content group is a built-in GA4 dimension, so it does not use one of your custom dimension slots.

Should blog posts get the group of the charge they discuss?

Usually yes. When posts share a group with their charge pages, the report shows everything a practice area brings in, from service pages and articles alike.

SBD Marketing works only with criminal defense firms, one firm per city. It helps with defense firm websites, SEO for the charges a firm handles, AI search visibility and SEO audits.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.