Sessions

Oppla automatically tracks user sessions to help you understand user behavior and engagement patterns. No additional configuration is needed beyond initializing Oppla.

What are Sessions?

A session in Oppla represents a continuous period of user activity on your website or application. Sessions help you understand:

  • How users interact with your content
  • When and how users engage with features
  • User journey patterns and flow
  • Conversion and drop-off points

Automatic Session Tracking

Sessions are tracked automatically once Oppla is initialized:

// Browser implementation
window.oppla.init({
  projectId: 'your-project-id'
});

// Node.js implementation
oppla.init({
  projectId: 'your-project-id'
});

Session Events

Oppla automatically tracks these session events:

// Session Started
{
  event: 'session_started',
  properties: {
    timestamp: '2024-03-20T10:00:00Z',
    sessionId: 'abc123',
    referrer: 'https://google.com',
    userAgent: 'Mozilla/5.0...'
  }
}

// Session Ended
{
  event: 'session_ended',
  properties: {
    timestamp: '2024-03-20T10:30:00Z',
    sessionId: 'abc123',
    duration: 1800, // seconds
    pageViews: 5
  }
}

// Session Extended
{
  event: 'session_extended',
  properties: {
    timestamp: '2024-03-20T10:15:00Z',
    sessionId: 'abc123',
    extensionCount: 1
  }
}

Tracking Events

Using Data Attributes

To track events, simply add a special data property to the element you want to track:

<!-- Basic event tracking -->
<button id="signup-button" data-oppla-event="Signup button">
  Sign up
</button>

<!-- Event tracking with additional data -->
<button 
  id="signup-button" 
  data-oppla-event="Signup button"
  data-oppla-event-email="bob@aol.com"
  data-oppla-event-id="123">
  Sign up
</button>

The additional properties will be recorded with the event:

{
  event: 'Signup button',
  properties: {
    email: 'bob@aol.com',
    id: '123'
  }
}

Using JavaScript

You can also track events manually using the Oppla object:

// Browser implementation
const button = document.getElementById('signup-button');
button.onclick = () => window.oppla.track('Signup button');

// With additional properties
button.onclick = () => window.oppla.track('Signup button', {
  email: 'bob@aol.com',
  id: '123'
});

// Node.js implementation
oppla.track('Signup button', {
  email: 'bob@aol.com',
  id: '123'
});

Important Notes

  1. Data Attributes:

    • Event data cannot be sent without an event name
    • All event data will be saved as strings
    • Other event listeners inside the element will not be triggered
  2. JavaScript Method:

    • Use for dynamic data
    • Supports all data types (numbers, dates, booleans, etc.)
    • Allows for more complex tracking logic

Viewing Events

Tracked events are available in your Oppla dashboard:

  1. Navigate to the Events page
  2. View event properties under the Properties tab
  3. See a breakdown of all custom data values

Best Practices

  1. Initialize Early:

    • Initialize Oppla as early as possible in your application
    • This ensures accurate session tracking from the start
  2. Track Key Milestones:

    • First interaction
    • Feature discovery
    • Conversion attempts
    • Goal completion
  3. Monitor Session Quality:

    • Bounce rates
    • Time on site
    • Page views per session
    • Conversion rates
  4. Analyze User Paths:

    • Common entry points
    • Popular navigation patterns
    • Drop-off points
    • Conversion paths

Next Steps