Event tracking
Learn how to track events for analysis and personalization.
Events track user interactions with your application, such as button clicks, content views, purchases, and more. They feed the personalization engine and help you measure how users interact with your application and track conversions.
The following sections provide examples of how you can use the Laravel SDK to track these events in your application.
Basic usage
To track an event, call the track method with the event name and its properties. Because tracking runs in the browser, you invoke it from your views with the @croct Blade directive, which runs the snippet once the SDK has loaded.
For example, to track a conversion when a user places an order:
@extends('layouts.app')
@section('content') <button id="place-order">Place order</button>
@croct const button = document.getElementById('place-order');
button.addEventListener('click', () => { croct.track('goalCompleted', {goalId: 'paymentApproved'}); }); @endcroct@endsectionFor the events worth tracking and their payloads, see the recommended events, and the Events reference for the complete list.