Installation
The Convultra JavaScript SDK can be installed in three ways depending on your use case. All methods result in the same SDK (~10KB gzipped, 36KB uncompressed).
Comparison
| Method A: Stub + Async | Method B: Sync Script | Method C: Async Only | |
|---|---|---|---|
| Best for | Conversion tracking (purchases, leads, signups) | Simple sites, OK with blocking | Traffic analytics only |
| Blocking | No | Yes (~10KB) | No |
| Race conditions | None — stub queues calls | None — SDK available after tag | Possible — SDK may not be ready when you call it |
| Conversion tracking | Yes | Yes | No (no stub to queue calls) |
| Auto-analytics | Yes | Yes | Yes |
| Recommended | Yes | For simple setups | For analytics-only |
Method A: Stub + Async Script (Recommended)
The recommended approach for any site that tracks conversions. Uses the same pattern as gtag.js — a lightweight stub queues calls while the full SDK loads asynchronously.
Best for: Conversion tracking (purchases, leads, signups, e-commerce events).
<!-- Convultra stub: queues calls before SDK loads -->
<script>
window.Convultra=window.Convultra||(function(){
var q=[];var c={q:q,initialized:false,config:{}};
['init','track','trackPurchase','trackLead','trackSignup','trackConversion',
'trackAddToCart','trackViewContent','trackBeginCheckout','enhance',
'setEnhancedUserData','identify','trackContact','trackSchedule',
'trackDownload','trackSubscription','trackAddPaymentInfo',
'trackAddToWishlist','trackSearch'].forEach(function(m){
c[m]=function(){q.push({m:m,a:Array.prototype.slice.call(arguments,0),t:Date.now()});return c;};
});
return c;
})();
</script>
<script async src="https://cdn.convultra.com/ultra.min.js" data-convultra-key="YOUR_API_KEY"></script>How it works:
- The inline stub creates a
window.Convultraobject with all SDK methods - Each method call pushes to an internal queue with a timestamp
- The
asyncscript downloads the full SDK without blocking page render - When the SDK loads, it drains the queue and processes every call in order
You can call Convultra.trackPurchase() or any other method immediately after the stub — even before the async script has loaded. The stub captures it, and the SDK processes it once ready.
Method B: Sync Script (No Stub)
A single script tag that blocks rendering until the SDK is loaded. The SDK is available immediately after the tag — no stub needed.
Best for: Simple sites where a brief render block (~10KB) is acceptable.
<script src="https://cdn.convultra.com/ultra.min.js" data-convultra-key="YOUR_API_KEY"></script>After this tag loads, window.Convultra is fully initialized:
<script src="https://cdn.convultra.com/ultra.min.js" data-convultra-key="YOUR_API_KEY"></script>
<script>
// Convultra is guaranteed to be ready here
Convultra.trackPurchase({
orderId: 'order_789',
value: 49.99,
currency: 'USD'
})
</script>This blocks rendering until the script downloads and executes. For most sites, Method A is preferred because it is non-blocking and handles the same use cases.
Method C: Async Script Only (Analytics Only)
A single async script tag with no stub. The SDK auto-tracks traffic analytics but you cannot reliably call conversion methods since there is no stub to queue calls before the SDK loads.
Best for: Traffic analytics only — no conversion tracking needed.
<script async src="https://cdn.convultra.com/ultra.min.js" data-convultra-key="YOUR_API_KEY"></script>Auto-tracked (no code required):
- Pageviews and page navigation
- Click IDs (
gclid,fbclid,msclkid) - Sessions and unique visitors
- Referrer and landing page
- UTM parameters (
utm_source,utm_medium,utm_campaign,utm_term,utm_content) - Device, browser, OS, and location
Do not use this method if you need to track conversions. Without the stub, calls made before the SDK loads will fail silently. Use Method A instead.
NPM Installation
Install the browser SDK via NPM for use in bundled applications (React, Vue, Next.js, etc.):
npm install @convultra/sdk-jsThen import and initialize:
import Convultra from '@convultra/sdk-js'
Convultra.init({ apiKey: 'YOUR_API_KEY' })
// Track a conversion
Convultra.trackPurchase({
orderId: 'order_123',
value: 99.99,
currency: 'USD'
})When using NPM, the SDK is bundled with your application code. No CDN script tag or stub is needed. The init() call replaces the data-convultra-key attribute.
Custom Domain
To serve the SDK from your own domain (avoids ad blocker detection of third-party scripts), configure a custom tracking domain in Dashboard → Settings → Custom Domain.
Once configured, replace the CDN URL:
<!-- Before -->
<script async src="https://cdn.convultra.com/ultra.min.js" data-convultra-key="YOUR_API_KEY"></script>
<!-- After -->
<script async src="https://track.yourdomain.com/v1/ultra.js" data-convultra-key="YOUR_API_KEY"></script>This works with all three installation methods. The SDK code is identical — only the delivery domain changes.
Source URLs
| Environment | URL |
|---|---|
| Production (minified) | https://cdn.convultra.com/ultra.min.js |
| Development (unminified, with source maps) | https://cdn.convultra.com/ultra.js |
| Custom domain | https://track.yourdomain.com/v1/ultra.js |
| NPM | @convultra/sdk-js |
Always use ultra.min.js in production. The unminified ultra.js build includes source maps and verbose logging — useful for debugging but not suitable for production.