# Anonymous User Tracking - StrikeX Events

### **JavaScript API Integration Documentation** <a href="#nitro-javascript-api-integration-documentation" id="nitro-javascript-api-integration-documentation"></a>

The *JS API Integration Guide (for Custom Script Installation)* provides step-by-step instructions for integrating SaleAssist’s JavaScript API into your website.\
It explains how to use various methods to identify visitors, track custom events, and implement SaleAssist’s tracking features after manually installing the script.

#### Table of Contents <a href="#table-of-contents" id="table-of-contents"></a>

1. Visitor Identification
2. Events Tracking\
   2.1. View Event\
   2.2. Update Cart Event\
   2.3. Checkout Event\
   2.4. Buy Event\
   2.5. Product View Event\
   2.6. Category View Event\
   2.7. Custom Events\
   2.8. High Intent Users

#### 1. Visitor Identification <a href="#h-1visitor-identification" id="h-1visitor-identification"></a>

Use **nitro.identify** method to identify visitors by providing their email, phone, and name.

```js
nitro.identify("<visitor_email>", "<visitor_phone>", "<visitor_name>");
```

#### 2. Events Tracking <a href="#h-2-events-tracking" id="h-2-events-tracking"></a>

Different events can be tracked with the help of methods enlisted below:

**2.1. View Event**

Use **nitro.view** method to track page views.

```js
// Example view event data
view_data = {
    page: "https://someurl.com"
}

// Track view event
nitro.view(view_data);
```

**2.2. Update Cart Event on add to cart**

Use **nitro.updatecart** method to track when items are added to the cart or removed from the cart. line\_items should contain all items currently in the cart.\
While sending update cart event send all the line items currently in cart. Trigger this event whenever anything in cart changes so that we can capture the timeline of cart activity in order.

```js
// Example add to cart event data
cart_data = {"line_items": line_items, "cart_value": cart_value}
cart_data = {
    cart_url: "https://someurl.com",
    product_id: 123456,
    line_items: [{
      "quantity": 1,
      "title": "Black Box",
      "line_price", 24.00,
      "id": "987654" (Variant Id),
      "product_id": "1234567",
      "image_url": "variant or product image url"
    },
    {
      "quantity": 1,
      "title": "Pink Box",
      "line_price", 20.00,
      "id": "987654" (Variant Id),
      "product_id": "1234568",
      "image_url": "variant or product image url"
    }],
    cart_value: 44.00
}

// Track add to cart event
nitro.updatecart(cart_data);
```

**2.3. Checkout Event**

Use **nitro.checkout** method to track checkout events.

```js
// Example checkout event data
checkout_data = {
    checkout: "<checkout_url>",
    items: [
        {
            product_id: 12345,
            price: 12.00,
            product_url: "https://someurl.com/product_id"
        },
                {
            product_id: 12346,
            price: 18.00,
            product_url: "https://someurl.com/product_id"
        }
    ],
    cart_value: <total_checkout_amount>,
}

// Track checkout event
nitro.checkout(checkout_data);
```

**2.4. Buy Event**

Use **nitro.buy** method to track purchase events.

```js
// Example buy event data
buy_data = {
    checkout_url: "https://someurl.com",
    order_id: "1231312312312",
    items: [
        {
            product_id: 12345,
            price: 12.00,
            product_url: "https://someurl.com/product_id"
        },
        {
            product_id: 12346,
            price: 12.00,
            product_url: "https://someurl.com/product_id"
        }
    ]
}

// Track buy event
nitro.buy(buy_data);
```

**2.5. Product View Event**

Use **nitro.productView** method to track product view events.

```js
// Example product view event data
product_data = {
    "title": "Your product title",
    "image": "https://pinkcans.myshopify.com/cdn/shop/files/Main.jpg?v=1718006767",
    "page": "https://pinkcans.myshopify.com/products/the-videographer-snowboard",
}
// Track product view event
nitro.productView(product_data);
```

**2.6. Category View Event**

Use **nitro.categoryView** method to track category view events.

```js
// Example category view event data
    category_data = {
"page" : "https://pinkcans.myshopify.com/collections/all",
"category" : "All",
}

// Track category view event
nitro.categoryView(category_data);
```

**2.7. Custom Events**

Use **nitro.track** method to track custom events.

```js
// Example custom event
nitro.track("<EVENT_NAME>", EVENT_VALUE);
```

* Replace **\<EVENT\_NAME>** with the name of your custom event and **EVENT\_VALUE** with the corresponding value.

***

**2.8. High Intent Users -**

Events to enter funnel = \["addtocart", "updatecart", "checkout"]

Events to exit funnel = "buy"
