UniPixel can track more than just page views and WooCommerce events. If there’s a button, link, form, or any element on your site that you want to track — you can set it up as a custom event and send it to Meta, Google, TikTok, Pinterest, or Microsoft.
This guide walks you through the entire process, including how to find the right selector for the element you want to track.
Before you can track something, you need to tell UniPixel which element to watch. UniPixel uses CSS selectors to identify elements. Don’t worry if that sounds technical — it’s simpler than it sounds.
A CSS selector is just a way to point at something on your page. There are three common types:
| Selector Type | What It Looks Like | Example |
|---|---|---|
| ID | #something | #signup-button |
| Class | .something | .cta-button |
| Attribute | [data-something="value"] | [data-action="subscribe"] |
IDs are the most reliable because they’re unique — only one element on the page should have a given ID. Classes can match multiple elements, which is sometimes what you want (track every “Add to Wishlist” button) and sometimes not.
Every browser has a built-in tool that lets you see the code behind any element on your page. Here’s how to use it:
To open the inspector:
A panel will open showing the HTML code, with the element you clicked highlighted.
What to look for:
You’ll see something like this:
<button id="get-started" class="btn btn-primary cta-main">Get Started</button>
From this, you can use:
#get-started — the ID (most reliable, unique on the page).cta-main — one of the classes (may match other elements too)button.cta-main — more specific: only <button> elements with that classAnother example:
<a href="/contact" class="nav-link contact-link">Contact Us</a>
.contact-link — the classa.contact-link — more specific: only links with that classIf the element has no ID or useful class:
<button class="btn btn-primary">Download Brochure</button>
If the class is too generic (like btn btn-primary which could match dozens of buttons), you have two options:
Option A: Add an ID yourself (recommended if you can edit the page)
Edit the page in WordPress and add an id attribute to the element. In most page builders (Elementor, WPBakery, Gutenberg), there’s an “Advanced” or “HTML ID” field in the element settings. Set it to something descriptive:
Then use #your-id-name as your selector in UniPixel.
Option B: Use a more specific selector
If you can’t edit the page, you can combine selectors to be more specific:
.hero-section .btn-primary — only the primary button inside the hero section[href="/contact"] — any link that points to the /contact pageform.newsletter button — the button inside a form with class “newsletter”Before entering the selector in UniPixel, confirm it matches the right element:
document.querySelectorAll('#your-selector') and press EnterIf it shows 1 element — perfect. That’s exactly what you want for a specific button.
If it shows multiple elements — your selector matches more than one thing. That might be intentional (tracking all “Add to Wishlist” buttons) or you may need a more specific selector.
If it shows 0 elements — the selector doesn’t match anything. Check for typos, or make sure you’re on the right page.
| Field | What to Enter |
|---|---|
| Element Reference | Your CSS selector — e.g. #get-started or .cta-button |
| Event Trigger | Choose “On Element Clicked” or “On Element Shown” (see below) |
| Event Name | What this event will be called in your platform’s dashboard — e.g. GetStartedClick, BrochureDownload, NewsletterSignup |
| Description | Your own note (not sent to the platform) — e.g. “Homepage hero CTA button” |
| Send Client-side | Leave ON — fires the event in the visitor’s browser |
| Send Server-side | Leave ON for Meta, TikTok, and Pinterest. For Google, only enable one (client OR server) to avoid double-counting |
On Element Clicked — fires when a visitor clicks the element. Use this for buttons, links, CTAs, download links, form submit buttons.
On Element Shown — fires the first time the element becomes visible on the screen (scrolls into view, or appears after page load). Use this for hero banners, promotional sections, sign-up forms, video embeds — anything where seeing it is the event you care about.
“On Element Shown” fires once per page load. If the visitor scrolls past it and back, it won’t fire again.
For most platforms, enable both. UniPixel automatically deduplicates — it sends the same event ID to both the browser pixel and the server API, so the platform counts it as one event, not two.
Exception — Google: Google only deduplicates the Purchase event. For all other events (including custom events), enabling both client and server will result in the event being counted twice in GA4. Pick one or the other for Google custom events.
Exception — Microsoft: Microsoft only supports client-side custom events. The server-side toggle is disabled.
If you want to track the same button click in Meta, TikTok, and Google, you need to add the custom event on each platform’s Events page separately. The CSS selector will be the same — you’re pointing at the same element — but the event name might differ depending on what each platform expects or what makes sense in each dashboard.
The event name is what appears in your platform’s reporting dashboard. Some tips:
HomepageCTAClick is better than Event1NewsletterSignup) or underscores (newsletter_signup)Lead, Contact, Subscribe. If your event matches one of these, use the platform’s name for better reporting. Otherwise, it will appear as a custom eventEvent not firing:
Event firing but not appearing in the platform dashboard:
Selector matches the wrong element:
“On Element Shown” fires immediately on page load:
| What You Want to Track | Suggested Selector | Trigger | Event Name |
|---|---|---|---|
| “Get Started” button with ID | #get-started | Click | GetStartedClick |
| All “Add to Wishlist” buttons | .add-to-wishlist | Click | AddToWishlist |
| Contact page link in navigation | a[href="/contact"] | Click | ContactNavClick |
| Newsletter signup form button | .newsletter-form button | Click | NewsletterSignup |
| Hero banner (visible on page) | #hero-banner | Shown | HeroBannerViewed |
| Promotional popup | .promo-modal | Shown | PromoViewed |
| Download PDF link | a[href$=".pdf"] | Click | PDFDownload |