Set Up Event Tracking
Last updated: March 18, 20266 min readIntermediateBrandDeveloper
The events SDK is a lightweight JavaScript library that captures events from your website. It buffers calls before initialization and respects consent settings automatically.
1
Add the SDK script
Add dataiq.js alongside your consent widget script.
2
Initialize the SDK
Call dataiq.init() with your API key after the page loads.
3
Track your first event
Call dataiq.track() to send a custom event.
javascript
<script src="https://cdn.arqam360.com/dataiq.js"></script>
<script>
dataiq.init({ apiKey: 'YOUR_API_KEY' });
</script>Tracking Custom Events
javascript
// Track a purchase event
dataiq.track('purchase', {
orderId: '12345',
amount: 99.99,
currency: 'SAR'
});Identifying Users
javascript
// Identify a known user
dataiq.identify({
userId: 'user_123',
email: 'user@example.com',
name: 'Ahmed'
});Page View Tracking
javascript
// Track a page view
dataiq.page('Product Page', {
category: 'Electronics',
productId: 'SKU-789'
});The events SDK buffers all calls made before init(). This means you can call track() and identify() anywhere in your code, even before the SDK is loaded — they'll be sent once initialization completes.
Was this article helpful?