Quickstart
Get event tracking running on your site in three steps. The CDN snippet is the recommended approach — it loads the SDK from Vendo’s CDN and buffers all calls before the SDK loads, so no events are lost.
Step 1: Add the Snippet
Paste this into your site’s <head>. Replace YOUR_WRITE_KEY with your write key and YOUR_TRACKING_ENDPOINT with your Cloud Run ingestion API URL.
<script>
(function(w,d,s,e,l,k){w['VendoObject']=e;w[e]=w[e]||function(){
(w[e].q=w[e].q||[]).push(arguments)};w[e].l=1*new Date();
l=d.createElement(s);k=d.getElementsByTagName(s)[0];
l.async=1;l.src='https://cdn.vendodata.com/sdk/v1/vendo.js';k.parentNode.insertBefore(l,k);
})(window,document,'script','vendo');
vendo('init', 'YOUR_WRITE_KEY', {
host: 'https://YOUR_TRACKING_ENDPOINT',
trackPageViews: true
});
</script>What this does:
- Creates a lightweight stub on
window.vendothat buffers all method calls - Loads the full SDK asynchronously from Vendo’s CDN (
cdn.vendodata.com) - Once the SDK loads, it replays all buffered calls in order
- Sends an automatic page view (via
trackPageViews: true)
The host option tells the SDK where to send events — this is your Cloud Run ingestion API URL (e.g., https://tracking-abc123.run.app). The SDK itself loads from the CDN; only event data goes to your endpoint.
You can call vendo('track', ...), vendo('identify', ...), etc. immediately — even before the SDK finishes loading. All calls are queued and replayed.
Step 2: Track Events
Now you can track events anywhere on your page:
<script>
// Track a custom event
vendo('track', 'Product Viewed', {
sku: 'SKU-1',
price: 29.99,
category: 'shoes'
});
// Identify a user (after login or signup)
vendo('identify', 'user-123', {
email: 'person@example.com',
name: 'Jane Smith',
plan: 'pro'
});
</script>That’s it. Events flow from the browser to your ingestion API to BigQuery.
Step 3: Verify Setup
- Open your browser’s Network tab and look for requests to
/collect - Confirm the response is
{ "ok": true, "received": 1, ... } - Check BigQuery for new rows in the
eventstable
Alternative: Self-Hosted Snippet
If you prefer serving the SDK from your own domain (for maximum first-party control), use the self-hosted async snippet. This loads the SDK from your ingestion API instead of the CDN.
See the Self-Hosting guide for full deployment instructions.
<script>
!function(){
var v=window.vendo=window.vendo||[];
if(!v._loaded){
v._loaded=!1;
v.methods=["track","identify","page","group","alias","reset","optOut","optIn","flush"];
v.factory=function(m){return function(){
v.push([m].concat(Array.prototype.slice.call(arguments,0)));return v
}};
for(var i=0;i<v.methods.length;i++){v[v.methods[i]]=v.factory(v.methods[i])}
v.load=function(k,o){
v._writeKey=k;v._options=o||{};
var s=document.createElement("script");s.async=!0;
s.src=(o&&o.host||"")+"/v1/sdk.js";
var f=document.getElementsByTagName("script")[0];
f.parentNode.insertBefore(s,f)
};
v.SNIPPET_VERSION="1.0.0"
}
}();
vendo.load("YOUR_WRITE_KEY", { host: "https://track.yourdomain.com" });
vendo.page();
</script>Both the CDN and self-hosted snippets use the same SDK and the same tracking API. The only difference is where the JavaScript file loads from.
Alternative: Direct Script Tag
If you prefer loading the SDK synchronously (no buffering):
<script src="https://cdn.vendodata.com/sdk/v1/vendo.js"></script>
<script>
const tracker = VendoTracker.init("YOUR_WRITE_KEY", {
endpoint: "https://YOUR_TRACKING_ENDPOINT/collect"
});
tracker.track("Product Viewed", { sku: "SKU-1" });
tracker.identify("user-123", { email: "person@example.com" });
</script>With this approach, VendoTracker.init() returns a tracker instance directly. Note that any calls before the script loads will fail — use the async snippet if you need to call tracking methods before the SDK is ready.
npm Module
Coming soon — The npm package
@vendo/trackingis not yet published. For now, use the CDN snippet or self-hosted snippet above.
Once available, SPAs (React, Vue, Next.js) will be able to install the SDK as a dependency:
npm install @vendo/trackingimport vendo from '@vendo/tracking';
vendo('init', 'YOUR_WRITE_KEY', {
host: 'https://YOUR_TRACKING_ENDPOINT',
trackPageViews: true
});What’s Next?
- JavaScript SDK — Full method reference, configuration options, and advanced features
- API Reference — The
/collectendpoint, event schema, and error codes - Self-Hosting — Deploy the ingestion API to Cloud Run