Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
rudderanalytics
✓ window.rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL');
✗ import { rudderanalytics } from 'rudder-sdk-js';
This deprecated package is typically loaded via a script tag, creating a global `window.rudderanalytics` object. Direct ESM/CJS module imports are not the primary or recommended way to interact with this SDK.
track
✓ window.rudderanalytics.track('Event Name', { property: 'value' });
✗ import { track } from 'rudder-sdk-js';
`track` is a method available on the global `rudderanalytics` object after successful initialization. This pattern is for the deprecated SDK.
Analytics (new package)
✓ import { Analytics } from '@rudderstack/analytics-js';
✗ import { Analytics } from 'rudder-sdk-js';
This import is for the *recommended migration target*, `@rudderstack/analytics-js`, which replaces `rudder-sdk-js`.
Demonstrates how to initialize the deprecated RudderStack JavaScript SDK via a script tag and track a product view event after it's ready, along with user identification.
<html>
<head>
<title>RudderStack Deprecated SDK Quickstart</title>
<script type="text/javascript">
!function(){var e=window.rudderanalytics=window.rudderanalytics||[];e.methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"],e.factory=function(t){return function(){var n=Array.prototype.slice.call(arguments);n.unshift(t);e.push(n);return e}};for(var t=0;t<e.methods.length;t++){var n=e.methods[t];e[n]=e.factory(n)}e.load=function(t,n){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.rudderlabs.com/rudder-analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a);e._writeKey=t;e._options=n};}();
// Initialize RudderStack (replace with your actual keys)
rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL');
rudderanalytics.ready(function() {
console.log('RudderStack SDK is ready!');
rudderanalytics.track('Product Viewed', {
productId: 'RS-123',
productName: 'Example Product',
category: 'Electronics'
});
rudderanalytics.identify('user-123', {
email: 'test@example.com',
plan: 'premium'
});
});
</script>
</head>
<body>
<h1>Welcome to the website!</h1>
<button onclick="rudderanalytics.track('Button Clicked', { buttonName: 'Test' })">Click Me</button>
<p>Check your browser console and network requests for RudderStack events.</p>
</body>
</html>
Errors
Common errors & fixes
ReferenceError: rudderanalytics is not defined
The SDK script has not loaded or executed correctly, or `rudderanalytics` is being accessed before it is globally available or before the `rudderanalytics.ready()` callback fires.
fixEnsure the SDK script tag is correctly placed in the `<head>` section of your HTML and that all RudderStack API calls are made within the `rudderanalytics.ready()` callback or explicitly after the script has fully loaded.
This package is deprecated and no longer maintained.
This message (or similar warnings during installation/build) indicates that you are using the `rudder-sdk-js` package, which has been officially deprecated by RudderStack.
fixMigrate your project to use the `@rudderstack/analytics-js` package. This new package offers enhanced features, ongoing maintenance, and critical security updates.
Audit
Dependencies
@rudderstack/analytics-jsrequiredThis package is deprecated; migration to `@rudderstack/analytics-js` is strongly recommended for ongoing support and features.