
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@framit/meta-pixel
Advanced tools
Simple, framework agnostic and GDPR Compliance library to track data to Meta Pixel
Famework agnostic and GDPR Compliance library to track user actions to Meta Pixel.
This library is a wrapper around Meta Pixel. The library does not depend on any frameworks or libraries, and can therefore be used within React, Vue, Angular and all others JS based applications.
npm install --save @framit/meta-pixel
or
yarn add @framit/meta-pixel
First your need to initialize Pixel with your pixelId.
import Pixel, { Config } from '@framit/meta-pixel';
const config: Config = {
pixelId: 'your-pixel-id',
autoConfig: true, // Optional, true as default.
isDebugMode: false; // Optional, false as default.
disablePushState: false, // Optional, false as default. It's not recommended to disable push state, read more at https://developers.facebook.com/ads/blog/post/2017/05/29/tagging-a-single-page-application-facebook-pixel
allowDuplicatePageViews: false // Optional, false as default.
}
Pixel.initialize(config);
If you do not initialize Pixel before tracking, you should get an error message within the dev-tools console: “Please initialize Pixel by calling Pixel.initialize({ pixelId: 'your-pixel-id' }) before start tracking.”
The library does not track any kind of events to Meta Pixel before the user has granted consent to beeing tracked. To tell the library that the user has granted the consents, you need to call the setHasGrantedConsent method, Pixel.setHasGrantedConsent()
.
When calling Pixel.revokeConsent()
, the tracking will be paused until the consent is granted by the user again.
Make sure you have initialized Pixel by calling Pixel.initialize({ pixelId: 'your-pixel-id' })
, before tracking user actions.
import { Pixel } from '@framit/meta-pixel';
// Example of tracking add item to cart actions
Pixel.trackSingle("your-pixel-id", "AddToCart", {
content_name: "Dont Make Me Think",
content_category: "Books > UX",
content_ids: ["guid-product-id"],
product_catalog_id: "product-catalog-id"
content_type: "product",
value: 199.0,
currency: "NOK",
});
// Tracking pageView based in history-state
Pixel.pageView();
// Tracking pageView based on custom eventId.
Pixel.pageView('my-awesome-event-id');
// Tracking Standard Events, read more at https://developers.facebook.com/docs/meta-pixel/implementation/conversion-tracking#standard-events
Pixel.track('Purchase', {
value: 199.0,
currency: "NOK"
});
// Tracking Standard Events, read more at https://developers.facebook.com/docs/meta-pixel/implementation/conversion-tracking#standard-events
Pixel.trackSingle('pixel-id','Purchase', {
value: 199.0,
currency: "NOK"
});
// Tracking Custom Events, custom events, which are visitor actions that you have defined and that you report by calling a Pixel function
Pixel.trackCustom('RecruitedAFriend', {
value: 199.0,
currency: "NOK"
});
// Tracking Custom Events, custom events, which are visitor actions that you have defined and that you report by calling a Pixel function
Pixel.trackSingleCustom('pixel-id','RecruitedAFriend', {
value: 199.0,
currency: "NOK"
});
To make sure your setup is sending data correctly to Meta, try out Facebook Pixel Helper Chrome Extension, https://chrome.google.com/webstore/detail/facebook-pixel-helper/fdgfkebogiimcoedlicjlajpkdmockpc/related
FAQs
Simple, framework agnostic and GDPR Compliance library to track data to Meta Pixel
The npm package @framit/meta-pixel receives a total of 45 weekly downloads. As such, @framit/meta-pixel popularity was classified as not popular.
We found that @framit/meta-pixel demonstrated a not healthy version release cadence and project activity because the last version was released 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.