Events
The package records what happens in your app as events, queues them on the phone, and sends them in batches every 30 seconds and when the app goes to the background. Your team uses them in segments, message triggers, workflows and goals.
Sent by themselves
Section titled “Sent by themselves”Without any code of yours, the package records the app opening, closing and being updated, the screens of its own you show, permission changes it is told about, taps on pushes, links opened, and everything users do with in-app messages and the messenger. These are standard events, on Settings › Audience › Data › Events.
Screens
Section titled “Screens”Name each of your screens as it shows:
crm.screen('wallet'); // records screen_viewed {screen: wallet}Use a name, the same every time; never a path or an id. Set CrmConfig.autoScreenViews: false if you name every screen yourself, the package’s included.
Your own events
Section titled “Your own events”-
Declare them in
CrmConfig.customEvents:CrmConfig(apiBase: Uri.parse('https://app.purrcrm.com'),appKey: const String.fromEnvironment('CRM_APP_KEY'),appVersion: '1.0.0',customEvents: const {'order_placed', 'table_booked'},) -
Record them:
crm.track('order_placed', {'total': '1250', 'items': '3'});
Names are lower case with underscores. Props are strings; PurrCRM reads a number, a date or money from its string by the event’s definition. Money is a whole number of the smallest unit, such as pence: 1250 for £12.50.
The package drops a name you did not declare in customEvents, and asserts in a debug build, so a typo is found at your desk. On PurrCRM, a new event is accepted the first time and marked for review, unless your app has Strict data on, when it must be defined on the Data page first. See Data.
Permissions
Section titled “Permissions”Tell the package when the user answers a permission:
crm.permissionChanged('push', allowed: true);Turning events off
Section titled “Turning events off”If a user turns product analytics off in your settings, start their session with CrmSession(guestId: id, productEventsOff: true): nothing is recorded for them.
From your backend
Section titled “From your backend”Events your servers see, such as a payment, are better sent from the backend, with the server API.