
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
react-use-snapchat-pixel
Advanced tools
react-use-snapchat-pixelreact-use-snapchat-pixel is a lightweight React hook library for integrating Snapchat Pixel with your React application. It provides an easy way to initialize and track events with Snapchat Pixel, allowing you to measure the effectiveness of your ads and understand user interactions.
Install the package via npm or yarn:
npm install react-use-snapchat-pixel
yarn add react-use-snapchat-pixel
Create an instance of SnapchatPixel and initialize it with your pixel ID:
// src/hooks/useSnapchatPixel.ts
import { useEffect, useState } from 'react';
import { SnapchatPixel } from 'react-use-snapchat-pixel';
const useSnapchatPixel = () => {
const [snapchatPixel, setSnapchatPixel] = useState<SnapchatPixel | null>(null);
useEffect(() => {
const initializeSnapchatPixel = async () => {
const pixel = new SnapchatPixel({
pixelID: 'PIXEL_ID',
});
pixel.init({});
setSnapchatPixel(pixel);
};
initializeSnapchatPixel();
}, []);
return snapchatPixel;
};
export default useSnapchatPixel;
Track simple events:
pixel.trackEvent('VIEW_CONTENT', {
item_ids: ['1234'],
});
Track events with optional data and additional information:
pixel.trackEvent('SUBSCRIBE', {
item_ids: ['1234', '5678'],
item_category: 'product',
price: 100.0,
currency: 'USD',
client_dedup_id: 'd2e6f4f5-8b43-4d4e-bd45-9d9e5e6b2d9a',
});
ADD_CARTADD_BILLINGADD_TO_WISHLISTAD_CLICKAD_VIEWAPP_OPENACHIEVEMENT_UNLOCKEDCOMPLETE_TUTORIALINVITELEVEL_COMPLETELIST_VIEWLOGINPAGE_VIEWPURCHASERATERESERVESAVESEARCHSHARESIGN_UPSPENT_CREDITSSTART_CHECKOUTSTART_TRIALSUBSCRIBEVIEW_CONTENTSnapchatPixelConstructor
new SnapchatPixel(props: Props)
pixelID (string): Your Snapchat Pixel ID.debug (boolean, optional): Enable or disable debug mode (default: true).pageViewOnInit (boolean, optional): Automatically track Page View event on initialization (default: true).Methods
init(props: InitProps): Initializes the Snapchat Pixel with optional properties.trackEvent<K extends TrackableEventName>(eventName: K, data?: TrackableEventData[K], additionalData?: AdditionalData): Tracks an event with optional data and additional information.getClientDeduplicationId(): Retrieves the passed client deduplication ID.Props Interface
pixelID (string): Your Snapchat Pixel ID.pageViewOnInit (boolean, optional): Automatically track PageView event on initialization.debug (boolean, optional): Enable or disable debug mode.InitProps Interface
user_email (string, optional): Email address of the currently signed-in user.ip_address (string, optional): IP address of the device.user_phone_number (string, optional): Phone number (digits only).user_hashed_email (string, optional): SHA256 hash of the lower-cased and whitespace-removed email address.user_hashed_phone_number (string, optional): SHA256 hash of the lowercase and whitespace-removed phone number.This package is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please submit issues and pull requests on the GitHub repository.
This package uses the Snapchat Pixel library for tracking and analytics. For more information, visit the Snapchat Pixel documentation.
FAQs
Typed wrapper around Snapchat Pixel
The npm package react-use-snapchat-pixel receives a total of 53 weekly downloads. As such, react-use-snapchat-pixel popularity was classified as not popular.
We found that react-use-snapchat-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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.