Install the tracking script
PixelMili's entire frontend footprint is a single async <script> tag.
It's under 10 KB gzipped, loads after the page, and never blocks render.
The snippet
Add this once, ideally just before </head>:
<script async src="https://track.pixelmili.com/t.js"
data-tracking-id="pm_YOUR_TRACKING_ID"></script>
What the script does
- Registers the
pm()global function for custom events. - Auto-fires a
PageViewon every page load. - Captures
_fbp,_fbc, UTM parameters, and referrer. - Sends to
track.pixelmili.com/collect(or your custom CNAME).
Firing custom events
After the script has loaded, call pm() with an event name and any extra data:
pm('track', 'AddToCart', {
value: 1299,
currency: 'BDT',
content_ids: ['SKU-123'],
content_type: 'product',
});
pm('track', 'Purchase', {
value: 4299,
currency: 'BDT',
content_ids: ['SKU-123', 'SKU-456'],
num_items: 2,
order_id: 'ORD-2026-0042',
});
Where to put calls
The standard e-commerce events are detected automatically — most sites need no calls at all. Only fire one yourself if auto-detection misses it on your site.
| Event | Auto-detected from |
|---|---|
PageView | Every page load. |
ViewContent | Product page (URL, og:type, or Product schema). |
AddToCart | Click on an add-to-cart / buy-now button. |
InitiateCheckout | Checkout page load. |
Purchase | Thank-you page (see below to set it exactly). |
Already have a Meta Pixel on your site?
PixelMili already sends every event to Meta server-side. If your site also runs its own Meta Pixel, those browser events carry a different event ID — Meta can't tell they're the same action and counts both. Pick one:
- Simplest: remove your Meta Pixel code. PixelMili's server-side events cover everything it was sending.
-
Keep the pixel (browser + server, as Meta recommends):
add
data-meta-pixel="mirror"to the PixelMili script, then in your pixel code deletefbq('track', 'PageView');and anyfbq('track', ...)calls for ViewContent, AddToCart, InitiateCheckout or Purchase. Keepfbq('init', ...). PixelMili then fires those events through your pixel with the same event ID it sends server-side, so Meta keeps exactly one.
<script async src="https://track.pixelmili.com/t.js"
data-tracking-id="pm_YOUR_TRACKING_ID"
data-meta-pixel="mirror"></script>
Not sure which applies? Open your site with the browser console open — the script prints a warning if it finds a Meta Pixel it isn't mirroring.
Pointing Purchase at your exact thank-you page
On a custom site (no plugin, no order webhook), the script detects your
thank-you/order-confirmation page automatically — it recognizes common URL
patterns, page titles, and order schema markup. That heuristic works for
most stores, but if your thank-you page has an unusual URL, tell the script
exactly where it is with data-success-url. When set, it's the
only thing that decides "is this the Purchase page" —
the automatic detection is skipped entirely, so an unrelated page can never
accidentally trigger a Purchase.
<script async src="https://track.pixelmili.com/t.js"
data-tracking-id="pm_YOUR_TRACKING_ID"
data-success-url="/order-complete/*"></script>
Use * as a wildcard for anything that varies (an order ID, a
transaction reference from your payment gateway, etc.) — it's matched
against the page path only, not the full URL, and is tolerant of a
trailing slash.
Reloading the thank-you page — or a customer navigating back to it later — never fires a duplicate Purchase. The script remembers which order it already sent (using the order ID when it can find one, the page path otherwise) and won't fire the same one twice, no matter how many times the page reloads.