# nextuser_sdk

> NextUser's Web Tracking Library

Latest version **1.0.5** (published 2023-07-18) · 0 weekly downloads

## Install

```sh
npm install nextuser_sdk
pnpm add nextuser_sdk
yarn add nextuser_sdk
bun add nextuser_sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-07-18 |
| First published | 2023-07-17 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nextuser |

## Links

- npm: https://www.npmjs.com/package/nextuser_sdk
- npm.io page: https://npm.io/package/nextuser_sdk

## Recent versions

- 1.0.5 (latest) — 2023-07-18
- 1.0.4 — 2023-07-17
- 1.0.3 — 2023-07-17

## README

# nu-ts-tracker
  Nextuser's tracking lib

# Installation
	npm install nextuser_sdk

# Usage

```js

//Import
import {nextuser, NUUser, NUUserGender, NUCart, NUCartItem, NUPurchaseDetails} from 'nextuser_sdk';

//Initialize Nextuser
var tid = 'internal_tests'; // your website id on Nextuser's Platform
nextuser.init(tid);

//Track Event
var event = '_my_first_event'
nextuser.track(event); // track event name
nextuser.track(event, 1, 2, 'sales'); // track event name + parameters (up to 10 parameters allowed)

//User Identification
var user = new NUUser();
user.email = 'a.lazea@gmail.com';
user.uid = '12345';
user.firstname = 'Ben';
user.lastname = 'Kenoby';
user.gender = NUUserGender.M;

nextuser.identify(user);

//User's variables tracking
var variables = {
	"var1":"val1",
    "var2":"val2"
};
nextuser.trackUserVariables(variables); // track user's variables, key/value pair of variableName/variableValue

//Cart

//Add to Cart
var cartItem = new NUCartItem();
cartItem.id = "123";
cartItem.quantity = 5;
cartItem.name = "product_name";
cartItem.category = "product_category";
cartItem.description = "product_desc";
nextuser.addToCart(cartItem); // adds a product to cart (if this product is already in the cart it's quantity value will be replaced by the current one)

//Remove from Cart
var productId = "123";
nextuser.removeItemFromCart(productId); // remove product with this id from cart

//Track Purchase
var cartTotal, details;

details = new NUPurchaseDetails();
details.discount = 200;
details.shipping = 1200;
details.tax = 300;
details.currency = "$";
details.incomplete = false;
details.paymentMethod = "card";
details.affiliation = "affiliation";
details.state = "MM";
details.city = "BM";
details.zip = "123456";

cartTotal = 1000;

nextuser.trackPurchase(cartTotal, details); // track purchase

//Browsed Products
nextuser.trackViewProduct(id); // track product browsed with this id 

```

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