Skip to content
  • There are no suggestions because the search field is empty.

Quickstart Guide

Get your first event tracked with the OIR SDK in minutes.

 

Prerequisites 

  1. Gather your integration credentials:

    • INTEGRATION-TYPE (oirtyp)
    • INTEGRATION-ID (oirid)
  2. Access to your website's HTML

Step 1: Install the SDK

Add the SDK script to your HTML <head> tag:

<script type="text/javascript">
!(function (s) {
var o = s.createElement('script'),
u = s.getElementsByTagName('script')[0];
o.src = 'https://cdn.aggle.net/oir/oir.min.js';
o.async = !0;
o.setAttribute('oirtyp', 'YOUR_INTEGRATION_TYPE');
o.setAttribute('oirid', 'YOUR_INTEGRATION_ID');
u.parentNode.insertBefore(o, u);
})(document);
</script>
 

Step 2: Track Your First Event

Page View

_oirtrk.push([
'event',
{
event: 'page_view',
payload: {
page_url: window.location.href,
page_title: document.title,
},
},
]);
 

Button Click

_oirtrk.push([
'event',
{
event: 'button_click',
payload: {
button_name: 'Sign Up',
page: '/home',
},
},
]);
 

Custom Event

_oirtrk.push([
'event',
{
event: 'newsletter_signup',
payload: {
source: 'footer',
campaign: 'spring_2024',
},
},
]);
 

Step 3: Set Global Data (Optional)

Set data that will be included with all events:

_oirtrk.push([
'set',
{
user_type: 'premium',
subscription_tier: 'pro',
},
]);
 

Step 4: Identify Users (Optional)

Associate user data with tracking:

_oirtrk.push([
'identify',
{
email: 'user@example.com',
first_name: 'John',
last_name: 'Doe',
},
]);
 

Complete Example

<!DOCTYPE html>
<html>
<head>
<title>My Website</title>

<!-- OIR SDK Installation -->
<script type="text/javascript">
!(function (s) {
var o = s.createElement('script'),
u = s.getElementsByTagName('script')[0];
o.src = 'https://cdn.aggle.net/oir/oir.min.js';
o.async = !0;
o.setAttribute('oirtyp', 'YOUR_INTEGRATION_TYPE');
o.setAttribute('oirid', 'YOUR_INTEGRATION_ID');

o.onload = function () {
// Track page view after SDK loads
window._oirtrk.push([
'event',
{
event: 'page_view',
payload: {
page_url: window.location.href,
page_title: document.title,
},
},
]);
};

u.parentNode.insertBefore(o, u);
})(document);
</script>
</head>
<body>
<h1>Welcome</h1>
<button onclick="trackClick()">Click Me</button>

<script>
function trackClick() {
window._oirtrk.push([
'event',
{
event: 'button_click',
payload: {
button_name: 'Click Me',
page: window.location.pathname,
},
},
]);
}
</script>
</body>
</html>
 

Verify Events

  1. Open browser DevTools (F12)
  2. Go to the Network tab
  3. Filter by "evt" or "aggle"
  4. Interact with your page and verify requests are being sent

What's Next?

  1. Installation Guide - Detailed installation options
  2. Custom Events Guide - Track custom business events
  3. Ecommerce Events - Ecommerce event tracking
  4. User Identification Guide - Learn about user identification