@polar-analytics/pixel-sdk
v0.4.2
Published
A JavaScript/TypeScript SDK for reporting customer touchpoints to Polar Analytics
Downloads
1,837
Readme
Pixel SDK
A lightweight JavaScript utility for reporting user touchpoints, similar to the Polar Analytics Pixel.
Installation
npm install @polar-analytics/pixel-sdk
Example usage
const payloadBase = await generatePayloadBase({
customer: {
// Optional, include if available
id: "some-id",
email: "some-email",
},
});
// An anonymous ID to identify the device + browser
// Please refer to https://community.shopify.com/c/shopify-apps/web-pixel-clientid/m-p/2664271/highlight/true#M80886
const shopifyClientId =
// <the url of the shopify store> i.e. something.myshopify.com
const shopifyShopUrl =
// Use the corresponding eventFactory for the desired event type.
const data = eventFactory.cart_viewed({
shopifyEventId: crypto.randomUUID(),
shopifyClientId,
shopifyShopUrl,
})
sendPixelEvent(
pixelEndpoint /* obtained from polar analytics */,
payloadBase,
{ data },
);