Common Attributes

Understand the key attribute used across Unbxd Analytics API for event tracking and session mapping.

The following attributes are utilized as parameters across various endpoints and resources within the API.

uid (userId)

A unique identifier (uid) is generated for each shopper, remaining consistent unless manually cleared. This uid is a random number tied to the shopper’s specific browser and device. If a shopper uses different browsers or devices, separate uids are created.

For consistent cross-device experiences, use your logged-in shopper’s customer ID instead of a random value.

NameType
uidString

How to Generate uid

To effectively manage sessions across multiple platforms with a shared catalog and user base, map each user to a unique uid. This supports seamless tracking.

  1. Default Behavior:

    var uid = 'uid-' + date.getTime() + '-' + Math.floor(Math.random() * 100000);
  2. For Logged-in Users:

    var uid = md5(customerId);

Constraints

  • Use the code patterns above to generate uid.
  • Store it (e.g., in cookies or localStorage) and pass it in API requests.
  • Avoid using personally identifiable information (e.g., unencrypted user IDs or device IDs).
  • Ensure compliance with GDPR and other data privacy standards.

visitId

A session or visit identifier that expires after 30 minutes of inactivity.

NameType
visitIdString

How to Generate visitId

  1. Web Browsers:
    Automatically created by the Netcore Unbxd Analytics script via cookies.

  2. Mobile Apps:

    visitId = 'visitId-' + now + '-' + Math.floor(Math.random() * 100000);

Constraints

  • Must expire after 30 minutes of inactivity.
  • When reset, a new "Visit" event must be triggered.

url

Refers to the page URL where the shopper initiated a search.

NameType
urlURL string

Example

If a shopper searches from the page:

https://www.example.com/electronics/laptops

Then url should capture this page — the origin of the search trigger — even before redirecting to the search results page.


referrer

Captures the URL of the page that led the user to the current one.

NameType
referrerURL string
referrer = sessionStorage.getItem('urlPrevious') || document.referrer || '';

Example

If a shopper navigates from:

https://www.example.com/gaming-laptops

to:

https://www.example.com/electronics/laptop-1

Then the referrer would be:

https://www.example.com/gaming-laptops

Useful for understanding navigation paths and traffic sources.


UnbxdKey

A unique site identifier key (also known as SiteKey) assigned to each environment (Dev, Stage, Prod).

NameType
UnbxdKeyString

How to Find Your SiteKey

  1. Log in to the Unbxd Console ↗
  2. Choose your site from the top dropdown.
  3. Navigate to: Manage > Configure Site > Keys
  4. Copy the key from the Keys page using the "Copy" button.

action

Indicates the type of user interaction being tracked (e.g., click, visit, search).

EventAction ValueData Type
Search HitsearchString
Add to CartcartString
VisitorvisitorString
Product ClickclickString
OrdersorderString

timestamp

Denotes the exact time when an event is triggered, combining the time in milliseconds with a random decimal for uniqueness.

NameType
timestamp (t)String
t = new Date().getTime() + '|' + Math.random();

Breakdown

  • new Date().getTime() — Current time in milliseconds since epoch.
  • '|' — Separator.
  • Math.random() — Adds uniqueness in case of duplicate millisecond timestamps.

Example

t = 1662365253141 | 0.6835012308821242

Ensures each event is uniquely identifiable even when triggered simultaneously.