samhub.js
    Preparing search index...

    Class Pixel

    Represents a Pixel tracking utility for sending event data to a specified API endpoint.

    const pixel = new Pixel("https://api.example.com/pixel.gif", "container123", console.log);
    pixel.send({ user_id: "user123", path: "/home" });
    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates an instance of the Pixel class.

      Parameters

      • apiUrl: string

        The API URL to be used for communication.

      • containerId: string

        The ID of the container where the pixel will be initialized.

      • Optionaldebug: (...args: any) => void

        An optional debug function for logging debug information. It accepts any number of arguments.

      Returns Pixel

    Properties

    apiUrl: string

    The API URL to which pixel data will be sent.

    containerId: string

    The container ID associated with the pixel.

    Methods

    • Sends tracking data to the specified API endpoint using a pixel image request.

      Parameters

      • data: EventData

        The event data to be sent. This should be an object containing the necessary information for the tracking event.

      • Optionalcallback: () => void

        An optional callback function that will be executed when the pixel image has successfully loaded.

        This method prepares the tracking data, logs it for debugging purposes, and sends it as a query string appended to the API URL. If a callback is provided, it will be triggered once the pixel image is loaded.

      Returns void