First, we don't actually measure the age of the Earth directly. The rocks on Earth are recycled too frequently. I don't think any have been dated much past 4 billion years.
Rather, we get the age of the Earth from measuring the age of asteroids, as the asteroids all formed at about the same time as the Earth, but don't have a pesky active crust and mantle to reset the ages of the rocks every few hundred million years.
As for actually measuring the ages themselves, that's typically performed using isochron dating (
https://en.wikipedia.org/wiki/Isochron_dating). The basis of the idea is that when the rock forms from some kind of molten substrate, it gets all mixed up, but does so in a way that follows the laws of chemistry.
For example, Rubidium has an isotope 87 that decays into Strontium 87. However, Rubidium and Strontium both have very different chemical properties, and don't form in the same locations. So a given rock will start with lots of Strontium and not much Rubidium in certain places, and the reverse in others. Measuring the ratios of the isotopes of Strontium and Rubidium throughout the rock will tell you how much of the Rb87 has decayed into Sr87.
This measures the rock's age to the last time it was in a liquid form. So you can use it to date lava rocks on Earth, or asteroids back to the time they originally formed, which measures the age of our Solar System, and therefore the Earth.