# @daisycon/tracking

> Daisycon JS tracking

Latest version **1.2.2** (published 2025-10-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @daisycon/tracking
pnpm add @daisycon/tracking
yarn add @daisycon/tracking
bun add @daisycon/tracking
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2025-10-10 |
| First published | 2021-07-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 113.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daisycon B.V. |
| Maintainers | sadrichem, chris-schardijn, mdaisycon, m.vanderwereld, barrykampstra |
| Keywords | Daisycon, Tracking |

## Links

- npm: https://www.npmjs.com/package/@daisycon/tracking
- Repository: https://github.com/DaisyconBV/js-tracking
- Homepage: https://github.com/DaisyconBV/js-tracking#readme
- Issues: https://github.com/DaisyconBV/js-tracking/issues
- npm.io page: https://npm.io/package/@daisycon/tracking

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2025-10-10
- 1.2.0 — 2025-04-23
- 1.1.3 — 2025-01-21
- 1.1.2 — 2024-04-18
- 1.1.1 — 2024-04-18
- 1.1.0 — 2024-04-18
- 1.0.0 — 2022-11-24
- 0.0.6 — 2021-08-02
- 0.0.5 — 2021-08-02
- 0.0.4 — 2021-07-27
- 0.0.3 — 2021-07-23
- 0.0.1 — 2021-07-23

## README

# Daisycon JS Tracking

## Installation

### Using yarn
```text
yarn add @daisycon/tracking
```

### Using npm
```text
npm install @daisycon/tracking
```

## Recommended usage (es6)

### Storing incoming requests
Add the following piece of code to the root of your app so that it loads on every page and stores any received dci.

```typescript
import {TrackingService} from '@daisycon/tracking';

new TrackingService()
	.storeData();
```


### Registering sale/lead
To register a lead or sale, you can use any of the examples below. 
* Replace the demo campaign ID (475) with your actual campaign ID provided to you by Daisycon
* Replace the segment (lt45.net) with the segment provided to you by Daisycon.
* Add your transaction ID and any other transaction data. (Check out the [transaction](blob/main/src/models/transaction.ts) model for what data you can provide)
* Add the transaction part. (Check out the [part](blob/main/src/models/transaction.ts) model for what data you can provide)

#### async await method

```typescript
import {CurrencyEnum, Part, SuccessInterface, TrackingService, Transaction} from '@daisycon/tracking';
const campaignId: number = 475;
const segment: string = 'lt45.net';

const transaction: Transaction = new Transaction({
	campaignId: campaignId,
	transactionId: 'AB374782388282',
}).addPart(new Part({
	amount: 125,
	revenue: 250,
	currency: CurrencyEnum.EUR,
	externalDescription: 'Transaction for Campaign',
}));

try {
	const successResponse: SuccessInterface = await new TrackingService(segment)
		.registerTransaction(transaction);

	console.log('successResponse', successResponse);

} catch (errorResponse: any) {
	console.log('errorResponse', errorResponse);
}
```

#### Regular promise method

```typescript
import {CurrencyEnum, Part, SuccessInterface, TrackingService, Transaction} from '@daisycon/tracking';
const campaignId: number = 475;
const segment: string = 'lt45.net';

const transaction: Transaction = new Transaction({
	campaignId: campaignId,
	transactionId: 'AB374782388282',
}).addPart(new Part({
	amount: 125,
	revenue: 250,
	currency: CurrencyEnum.EUR,
	externalDescription: 'Transaction for Campaign',
}));

new TrackingService(segment)
	.registerTransaction(transaction)
	.then((successResponse: SuccessInterface) => console.log('successResponse', successResponse))
	.catch((errorResponse: any) => console.log('errorResponse', errorResponse));
```

#### Alternate transaction definition

```typescript
import {CurrencyEnum, Part, SuccessInterface, TrackingService, Transaction} from '@daisycon/tracking';
const campaignId: number = 475;
const segment: string = 'lt45.net';

const myData: any = {
	currencyCode: 'EUR',
	transactionId: '1234Acef',
	products: [
		{name: 'test', price: 25.01},
		{name: 'test 2', price: 2.95},
	]
};

const transaction: Transaction = new Transaction({
	campaignId: campaignId,
	transactionId: myData.transactionId,
	parts: myData.products.map((product: any) => {
		return new Part({
			amount: product.price,
			revenue: product.price,
			currency: <CurrencyEnum>myData.currencyCode,
			externalDescription: product.name,
		});
	})
});

new TrackingService(segment)
	.registerTransaction(transaction)
	.then((successResponse: SuccessInterface) => console.log('successResponse', successResponse))
	.catch((errorResponse: any) => console.log('errorResponse', errorResponse));
```

## Alternate usage (commonjs)

### Storing incoming requests
Add the following piece of code to the root of your app so that it loads on every page and stores any received dci.

```typescript
const daisycon = require('@daisycon/tracking');

new daisycon.TrackingService()
	.storeData();
```

### Registering sale/lead
#### async await method

```typescript
const daisycon = require('@daisycon/tracking');
const campaignId: number = 475;
const segment: string = 'lt45.net';

const transaction: daisycon.Transaction = new daisycon.Transaction({
	campaignId: campaignId,
	transactionId: 'AB374782388282',
}).addPart(new daisycon.Part({
	amount: 125,
	revenue: 250,
	currency: daisycon.CurrencyEnum.EUR,
	externalDescription: 'Transaction for Campaign',
}));

try {
	const successResponse: SuccessInterface = await new daisycon.TrackingService(segment)
		.registerTransaction(transaction);

	console.log('successResponse', successResponse);

} catch (errorResponse: any) {
	console.log('errorResponse', errorResponse);
}
```

## Alternate usage manual import

### Storing incoming requests
Add the following piece of code to the root of your app so that it loads on every page and stores any received dci.

```html
<script src="/path/to/build/daisycon-bundle.min.js"
```

```javascript
new daisycon()
	.storeData();
```

### Registering sale/lead
#### async await method

```javascript
const campaignId: number = 475;
const segment: string = 'lt45.net';

try {
	const successResponse = await new daisycon(segment)
		.registerTransaction({
			campaignId: campaignId,
			transactionId: 'AB374782388282',
			parts: [{
				amount: 125,
				revenue: 250,
				currency: daisycon.CurrencyEnum.EUR,
				externalDescription: 'Transaction for Campaign',
			}]
		});

	console.log('successResponse', successResponse);

} catch (errorResponse) {
	console.log('errorResponse', errorResponse);
}
```

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