# @snowplow/browser-plugin-ecommerce

> Ecommerce tracking for Snowplow

Latest version **3.24.6** (published 2024-10-28) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @snowplow/browser-plugin-ecommerce
pnpm add @snowplow/browser-plugin-ecommerce
yarn add @snowplow/browser-plugin-ecommerce
bun add @snowplow/browser-plugin-ecommerce
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.24.6 |
| Published | 2024-10-28 |
| First published | 2021-03-08 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 600.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 593 |
| Author | Paul Boocock |
| Maintainers | snowplow-analytics, cogsp, paul_boocock |

## Links

- npm: https://www.npmjs.com/package/@snowplow/browser-plugin-ecommerce
- Repository: https://github.com/snowplow/snowplow-javascript-tracker
- Homepage: http://bit.ly/sp-js
- Issues: https://github.com/snowplow/snowplow-javascript-tracker/issues
- npm.io page: https://npm.io/package/@snowplow/browser-plugin-ecommerce

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [@snowplow/tracker-core](https://npm.io/package/@snowplow/tracker-core.md) 3.24.6
- [@snowplow/browser-tracker-core](https://npm.io/package/@snowplow/browser-tracker-core.md) 3.24.6

## Recent versions

- 3.24.6 (latest) — 2024-10-28
- 3.13.2-dev.0 (1185-id-service-option) — 2023-07-04
- 3.13.1-dev.0 (add-tracking-scenario-option-to-core) — 2023-06-22
- 3.9.0-beta.1 (next) — 2023-01-17
- 3.24.5 — 2024-10-25
- 3.24.4 — 2024-09-26
- 3.24.3 — 2024-09-03
- 3.24.2 — 2024-07-24
- 3.24.1 — 2024-07-02
- 3.24.0 — 2024-06-25
- 3.23.1 — 2024-06-04
- 3.23.0 — 2024-03-28
- 3.22.1 — 2024-03-13
- 3.22.0 — 2024-03-08
- 3.21.0 — 2024-01-29
- … 49 more at https://npm.io/package/@snowplow/browser-plugin-ecommerce/versions

## README

# Snowplow Ecommerce Tracking

[![npm version][npm-image]][npm-url]
[![License][license-image]](LICENSE)

Browser Plugin to be used with `@snowplow/browser-tracker`.

Adds ecommerce events to your Snowplow tracking.

## Maintainer quick start

Part of the Snowplow JavaScript Tracker monorepo.  
Build with [Node.js](https://nodejs.org/en/) (18 - 20) and [Rush](https://rushjs.io/).

### Setup repository

```bash
npm install -g @microsoft/rush 
git clone https://github.com/snowplow/snowplow-javascript-tracker.git
rush update
```

## Package Installation

With npm:

```bash
npm install @snowplow/browser-plugin-ecommerce
```

## Usage

Initialize your tracker with the EcommercePlugin:

```js
import { newTracker } from '@snowplow/browser-tracker';
import { EcommercePlugin } from '@snowplow/browser-plugin-ecommerce';

newTracker('sp1', '{{collector}}', { plugins: [ EcommercePlugin() ] }); // Also stores reference at module level
```

Then use the available functions from this package to track to all trackers which have been initialized with this plugin:

```js
import { addTrans, addItem, trackTrans, trackAddToCart } from '@snowplow/browser-plugin-ecommerce';

trackAddToCart({
  sku: '000345',
  name: 'blue tie',
  category: 'clothing',
  unitPrice: 3.49,
  quantity: 2,
  currency: 'GBP',
});

// Grouped, events are sent on `trackTrans()` call
addTrans({
  orderId: 'order-123',
  total: 8000,
  affiliation: 'acme',
  tax: 100,
  shipping: 50,
  city: 'pheonix',
  state: 'arizona',
  country: 'USA',
  currency: 'JPY',
});
addItem({
  orderId: 'order-123',
  sku: '1001',
  name: 'Blue t-shirt',
  category: 'clothing',
  price: '2000',
  quantity: '2',
  currency: 'JPY',
});
trackTrans();
```

## Copyright and license

Licensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).

Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang.

All rights reserved.

[npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-ecommerce
[npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-ecommerce
[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/
[osi]: https://opensource.org/licenses/BSD-3-Clause
[license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-ecommerce

---
_Source: https://npm.io/package/@snowplow/browser-plugin-ecommerce · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
