Installation
The Upstack pixel is distributed via CDN, not npm. Add this snippet to your site’s<head>:
- The inline script defines
_upstack()as a function that pushes calls to a queue - Calls made before the SDK loads are queued — no events are lost
- Once the SDK loads, it processes the queue and replaces
_upstack()with the real implementation - Safe to call immediately without checking load status
API Overview
Queue Commands
These methods can be called via_upstack('command', ...) before or after the SDK loads.
init(pixelId)
Initialize the Upstack pixel with your pixel ID.
Examples:
page(eventData?)
Track a page view. Automatically captures page URL, title, referrer, and path.
Auto-captured properties:
page_url— Current page URLpage_title— Document titlepage_referrer— Referring URLpage_path— URL path
track(eventName, eventData?, …)
Track a custom event. Supports 7 positional parameters plus a shorthand foruseBeacon.
Shorthand for useBeacon:
When the 4th argument is an object with
useBeacon, it’s treated as options:
identify(userId?, data?)
Associate user identity with the current session. Used for cross-device tracking and destination matching.Important:
emails and phones are arrays, not single values. This supports users with multiple contact methods.metric(metricName, metricValue, metricData?, metricId?)
Send a custom metric value.
Example:
reset()
Clear identity, session data, event listeners, and hooks. Call when a user logs out.Direct Client Methods
These methods are only available viawindow._upsClient after initialization completes. They cannot be called through the _upstack() queue.
isKnown()
Check if the current user has been identified.true if the user has been identified, false otherwise.
Example:
getUpstackId()
Retrieve the Upstack identity object for the current user.UpstackId object (not a string).
Example:
Waiting for SDK Ready
When using direct client methods, ensure the SDK has loaded:Common Patterns
SPA Navigation Tracking
Track page views on route changes in single-page applications:E-commerce Funnel
Track the complete customer journey:Page Exit Tracking with Beacon
Reliably track time on page even when the user closes the tab:Form Submission Tracking
Capture leads from newsletter signups:TypeScript Support
Add type declarations for TypeScript projects:Methods NOT Available
The following methods are not implemented in the public SDK:consent— Not implementedgroup— Not implemented (stub exists)screen— Not implemented (stub exists)alias— Not implemented (stub exists)
notify— Internal hook messagingpostInit— Internal post-initialization
Related Documentation
Pixel Setup
Installation guide for non-Shopify websites and SPAs.
Standard Events
Complete reference for all standard events with JavaScript snippets.
Properties & Context
Reference for item arrays, customer data, and auto-captured fields.
Custom Events
Create events beyond the standard taxonomy for your needs.
Identity Resolution
How identify() connects sessions to customer profiles.
Shopify Automatic Tracking
Events tracked automatically on Shopify stores.