Quickstart Guide
Get your first event tracked with the OIR SDK in minutes.
Prerequisites
-
Gather your integration credentials:
- INTEGRATION-TYPE (
oirtyp) - INTEGRATION-ID (
oirid)
- INTEGRATION-TYPE (
-
Access to your website's HTML
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>
_oirtrk.push([
'event',
{
event: 'page_view',
payload: {
page_url: window.location.href,
page_title: document.title,
},
},
]);
_oirtrk.push([
'event',
{
event: 'button_click',
payload: {
button_name: 'Sign Up',
page: '/home',
},
},
]);
_oirtrk.push([
'event',
{
event: 'newsletter_signup',
payload: {
source: 'footer',
campaign: 'spring_2024',
},
},
]);
Set data that will be included with all events:
_oirtrk.push([
'set',
{
user_type: 'premium',
subscription_tier: 'pro',
},
]);
Associate user data with tracking:
_oirtrk.push([
'identify',
{
email: 'user@example.com',
first_name: 'John',
last_name: 'Doe',
},
]);
<!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>
- Open browser DevTools (F12)
- Go to the Network tab
- Filter by "evt" or "aggle"
- Interact with your page and verify requests are being sent
- Installation Guide - Detailed installation options
- Custom Events Guide - Track custom business events
- Ecommerce Events - Ecommerce event tracking
- User Identification Guide - Learn about user identification