next-facebook-tracking
Version:
A simple package to help you integrate Facebook Pixel and Conversions API with Next.js
34 lines (31 loc) • 1.01 kB
TypeScript
import { Facebook } from '../types.js';
import { JSX } from 'react';
/**
* Component to track onClick events using Facebook Pixel.
*
* @example
* // Usage example
* <FacebookTrackOnClick event={{
* event_name: "InitiateCheckout",
* custom_data: { content_name: "Test Product" },
* }} action={facebook.track}>
* <button>Click me</button>
* </FacebookTrackOnClick>
*/
declare function FacebookTrackOnClick<T extends Facebook.Event.EventName, TD extends Facebook.BrowserEvent<T>>({ children, event, action, ...rest }: {
/**
* The event to track that will be sent to Facebook when the component is clicked.
*/
event: TD;
/**
* The clickable content to render inside the component.
*/
children: React.ReactNode;
/**
* A server-side action that will be called after the click handler is called.
*/
action?: (props: Omit<TD, 'event_id'> & {
event_id: string;
}) => Promise<void>;
}): JSX.Element;
export { FacebookTrackOnClick };