Pixel Plugin

View as Markdown
Last updated November 5, 2026

Send data using an img element

pixel plugin

Send data using an img element

Pixel
namespace pixel
pixel utility

Interfaces

PixelOptions

properties
  • src string - the URL of the pixel to send data to
  • success optional PixelSuccessCallback - a callback to call on success
  • failure optional PixelFailureCallback - a callback to call on failure

PixelSuccessCallback

  • Type () => void;

PixelFailureCallback

  • Type (reason: any) => void;

Plugin API

pixel(options: PixelOptions): void;

Send data using an img element.

parameters
example
jstag.use(plugin => {
  plugin.pixel({
    src: 'https://doesnt.exist/pixel.gif?data=whatever',

    success() {
      console.log('data sent!');
    },

    failure() {
      console.error('data not sent!');
    }
  })
});

Mechanism

This plugin works by appending an <img> element to the DOM.

Events

EventFires whenPayload
pixel.succeededthe pixel request completes successfully.the pixel URL
pixel.failedthe pixel request fails.the pixel URL

Learn more about events