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

  1. Open the page with the button.
  2. Right-click the button and choose Inspect.
  3. 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">
  1. The class is everything inside class="...". Here that’s two classes: elementor-button and book-now.
  2. The ID is inside id="...". Here it’s hero-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:

  1. Open Safari → Settings → Advanced.
  2. Tick Show features for web developers (on older versions, Show Develop menu in menu bar).
  3. 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__link or btn. 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.

Sometimes you can’t edit the button at all. You can still target it by where it links to:

To matchSelector
Links containing “checkout”a[href*="checkout"]
Phone number linksa[href^="tel:"]
Email linksa[href^="mailto:"]
PDF downloadsa[href$=".pdf"]

These work in WP Click Tracker, Google Tag Manager and your own CSS.