How to find the CSS class or ID of any button on your website
Every click tracker, Tag Manager trigger and custom style starts with this. It takes under a minute.
To track, style or target a button, you need something that identifies it: its class or its ID. You don’t need any developer tools installed. Every modern browser has what you need built in.
In Chrome or Edge
- Open the page with the button.
- Right-click the button and choose Inspect.
- A panel opens with the button’s HTML highlighted. It looks something like this:
<a href="/book/" class="elementor-button book-now" id="hero-book">
- The class is everything inside
class="...". Here that’s two classes:elementor-buttonandbook-now. - The ID is inside
id="...". Here it’shero-book.
If the highlighted line is a <span> or an icon inside the button, look one or two lines up for the <a> or <button> that contains it.
In Firefox
Right-click the button and choose Inspect. Everything else works the same as in Chrome.
In Safari
Safari hides the developer tools by default. Switch them on first:
- Open Safari → Settings → Advanced.
- Tick Show features for web developers (on older versions, Show Develop menu in menu bar).
- Now right-click the button and choose Inspect Element.
Which one should you use?
- Use the ID if there is one and you only want to track that single button. In a CSS selector it starts with
#, for example#hero-book. - Use a class if the same button appears in several places and you want them counted together. In a CSS selector it starts with
., for example.book-now. - Avoid generic classes such as
elementor-button,wp-block-button__linkorbtn. Every button on your site probably has them, so you’d be counting all buttons at once.
The button has no useful class
That’s common with page builders. The fix is to give the button its own class. It takes ten seconds and doesn’t change how it looks:
- Block editor: select the button, open Advanced in the sidebar, and type a class in Additional CSS class(es).
- Elementor: edit the button, open the Advanced tab and fill in CSS Classes.
- Divi: open the button’s settings, go to Advanced → CSS ID & Classes.
Use something descriptive, such as book-now or pricing-cta. There are more examples in tracking clicks in Elementor, Divi and the block editor.
Track links without touching them
Sometimes you can’t edit the button at all. You can still target it by where it links to:
| To match | Selector |
|---|---|
| Links containing “checkout” | a[href*="checkout"] |
| Phone number links | a[href^="tel:"] |
| Email links | a[href^="mailto:"] |
| PDF downloads | a[href$=".pdf"] |
These work in WP Click Tracker, Google Tag Manager and your own CSS.