
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@adkit.so/meta-pixel
Advanced tools
The most powerful and developer-friendly Meta Pixel integration for JavaScript & TypeScript applications.
A platform-agnostic wrapper for Meta Pixel that provides a seamless, type-safe experience with advanced features like event deduplication, multiple pixel support, and beautiful debug logging.
npm install @adkit.so/meta-pixel
import META from '@adkit.so/meta-pixel';
// 1. Initialize
META.init({ pixelIds: 'YOUR_PIXEL_ID' });
// 2. Track events
META.track('Purchase', { value: 99.99, currency: 'USD' });
That's it! 🎉
npm install @adkit.so/meta-pixel
Initialize the pixel as early as possible in your application entry point (e.g., main.ts, App.jsx, index.js).
import META from '@adkit.so/meta-pixel';
META.init({
pixelIds: '1234567890',
autoTrackPageView: true, // default: true
});
// Track standard events
META.track('AddToCart', {
value: 29.99,
currency: 'USD',
content_ids: ['SKU_123'],
content_type: 'product',
});
// Track custom events
META.trackCustom('MyCustomEvent', {
custom_param: 'value',
});
If you need separate instances for different parts of your application (rare):
import { createMetaPixel } from '@adkit.so/meta-pixel';
const marketingPixel = createMetaPixel();
marketingPixel.init({ pixelIds: 'MARKETING_ID' });
const productPixel = createMetaPixel();
productPixel.init({ pixelIds: 'PRODUCT_ID' });
| Option | Type | Default | Description |
|---|---|---|---|
pixelIds | string | string[] | '' | Required. Single pixel ID or array of pixel IDs |
autoTrackPageView | boolean | true | Automatically track PageView on initialization |
debug | boolean | false | Enable styled console logs with background colors |
enableLocalhost | boolean | false | Enable tracking on localhost (useful for testing) |
META.init({
pixelIds: ['PIXEL_ID_1', 'PIXEL_ID_2', 'PIXEL_ID_3'],
debug: true,
});
All Meta Pixel standard events are supported with full TypeScript autocomplete. These events help you track important actions on your website and optimize your ad campaigns.
| Event | Description | Common Use Cases |
|---|---|---|
AddPaymentInfo | Payment info added | Checkout flow |
AddToCart | Item added to shopping cart | E-commerce |
AddToWishlist | Item added to wishlist | E-commerce |
CompleteRegistration | User completed registration | Sign-ups, account creation |
Contact | User contacted business | Contact forms |
CustomizeProduct | Product customization started | Product configurators |
Donate | Donation made | Non-profits |
FindLocation | Location finder used | Store locators |
InitiateCheckout | Checkout process started | E-commerce funnels |
Lead | Lead submitted | Lead generation forms |
Purchase | Purchase completed | Transaction confirmation |
Schedule | Appointment scheduled | Booking systems |
Search | Search performed | Site search |
StartTrial | Trial started | SaaS applications |
SubmitApplication | Application submitted | Job boards, loan applications |
Subscribe | Subscription started | Newsletters, subscriptions |
ViewContent | Content viewed | Product pages, blog posts |
You can find the official list of standard events here.
All event parameters are optional but help improve ad targeting and conversion tracking.
| Parameter | Type | Description | Example |
|---|---|---|---|
value | number | Monetary value of the event | 99.99 |
currency | string | ISO 4217 currency code | 'USD', 'EUR', 'GBP' |
content_ids | string[] | Product IDs or SKUs | ['SKU_123', 'SKU_456'] |
content_type | string | Type of content | 'product', 'product_group' |
content_name | string | Name of page/product | 'Blue T-Shirt' |
content_category | string | Category of page/product | 'Apparel', 'Electronics' |
contents | Array<{id, quantity}> | Detailed product information | [{id: 'SKU_123', quantity: 2}] |
num_items | number | Number of items | 3 |
search_string | string | Search query | 'running shoes' |
status | boolean | Registration/subscription status | true |
predicted_ltv | number | Predicted lifetime value of customer | 450.00 |
You can find the list of properties here
Prevent duplicate event tracking by using unique event IDs. This is crucial when tracking conversions from both client and server (CAPI).
const orderId = '12345';
META.track(
'Purchase',
{
value: 299.99,
currency: 'USD',
content_ids: ['SKU_123'],
},
{
eventID: `order-${orderId}`, // Unique Event ID
},
);
Useful if you need to conditionally run logic based on whether the pixel script has loaded.
if (META.isLoaded()) {
META.track('Purchase', { value: 99.99, currency: 'USD' });
} else {
console.log('Pixel not loaded yet');
}
When debug: true is passed to init(), you'll see beautiful styled console logs:
META.init({
pixelIds: 'YOUR_ID',
debug: true,
});
This package is written in TypeScript and bundles type definitions.
import type { StandardEvent, EventData, MetaPixelConfig } from '@adkit.so/meta-pixel';
const config: MetaPixelConfig = {
pixelIds: '123',
};
const eventData: EventData = {
value: 100,
currency: 'USD',
};
debug: true in init() to see detailed logsenableLocalhost: true if testing locallyLearn more about Meta Pixel from official Facebook resources:
Using a framework? Check out our dedicated packages:
@adkit.so/meta-pixel-nuxt@adkit.so/meta-pixel-react@adkit.so/meta-pixel-nextFor a complete step-by-step guide on installing and configuring Meta Pixel, check out our detailed tutorial:
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
MIT
Made with ❤️ by Adkit
If this package helped you, please consider giving it a ⭐️ on GitHub!
FAQs
Platform-agnostic Meta Pixel tracking wrapper with TypeScript support
We found that @adkit.so/meta-pixel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.