Track Custom Events
See which events your app records, add your own from your website, and send orders so revenue shows in App Analytics.
Custom events are the actions that matter to your business, such as add to cart or newsletter signup. App Analytics counts them on the Engagement tab, next to your pages.
Events your app already records
You don't need to write any code for these. They are recorded in Twinr automatically:
- Events you set up in Custom Events: webpage element clicks and
twinr_firebase_analytics_eventcalls. - Events on your app's elements: hamburger menu items and navigation bar buttons with Track Click Event on.
These need the Premium plan or your free trial, and no Firebase setup. The event name in Twinr is the name you entered, in lowercase. A name that breaks the event name rule isn't tracked.
Add events from your website
Your website runs inside your app, so it can record events too. This gives you the most freedom: any action on any page, with the details you choose. Call twinr_track from your page's JavaScript:
twinr_track('add_to_cart', {
product_id: 'SKU-123',
price: 19.99,
in_stock: true
});
The second argument, the event's properties, is optional. Your own event names need the Premium plan or your free trial. See Track Events and Users for the guard to add first and how to check your setup.
If an action already has an event set up in Custom Events, don't also send it with twinr_track, or it is counted twice.
Rules for names and properties
| What | Rule |
|---|---|
| Event name | Starts with a lowercase letter, then lowercase letters, digits or _. Up to 64 characters. |
| Properties per event | Up to 25 |
| Property value | Text up to 255 characters, a number, or true/false |
Use lowercase words joined by underscores, and name the action rather than the button: checkout_started, not blue_button_click.
Reserved events
Two event names are reserved for sales. Send them when an order completes, and the Revenue tab shows your revenue, orders and top products. Each order is counted once, even if the event is sent twice. These two names work on every active plan.
order_completed
Send one per order.
twinr_track('order_completed', {
order_id: 'A-1001', // required
value: 49.99, // required: the order total, a number
currency: 'USD', // required: three capital letters
discount_code: 'SPRING', // optional
item_count: 2, // optional
subscription_id: 'S-77', // optional
source: 'web' // optional
});
product_purchased
Send one for each product in the order, with the same order_id.
twinr_track('product_purchased', {
order_id: 'A-1001', // required
product_id: 'SKU-123', // required
name: 'Blue shirt', // required
price: 19.99, // required: the price of one item
quantity: 2, // required: a whole number, 1 or more
currency: 'USD', // required
variant_id: 'SKU-123-M', // optional
category: 'Shirts' // optional
});
If your store is connected through the Twinr Shopify or WooCommerce plugin, its orders are already sent. You don't need these events for them.
Where to see your events
Open App Analytics and choose the Engagement tab. Custom events lists each event with how many times it happened and by how many people. Choose Details to see an event over time and its most common property values.
Under Developer tools:
- Recent events shows the last 100 page views and custom events from your app, so you can check that a new event arrives.
- Rejected events shows events Twinr turned away in the last 7 days, why, and an example name. A reserved event with a missing or wrong property is rejected here.