Event Properties Reference
This document lists all properties automatically tracked by the Grain Analytics SDK and those that developers need to collect manually.Legend
- β Auto-tracked: Automatically collected by the SDK
- π§ Developer-collected: Must be manually tracked by developers
- π Consent-required: Only collected with user consent
Standard Events
page_view
Automatically tracked on every page navigation.
| Property | Type | Tracking | Description |
|---|---|---|---|
page | string | β | Current page path (with or without query params based on config) |
title | string | β π | Document title |
full_url | string | β π | Complete URL including query params and hash |
referrer | string | β π | Previous page URL (document.referrer) |
referrer_domain | string | β π | Domain extracted from referrer |
referrer_category | string | β π | Categorized referrer: organic, paid, social, direct, email, referral |
previous_page | string | β π | Previous page within the same session |
landing_page | string | β π | First page of the session (only on subsequent page views) |
session_id | string | β π | Current session identifier |
utm_source | string | β π | UTM source parameter (if present) |
utm_medium | string | β π | UTM medium parameter (if present) |
utm_campaign | string | β π | UTM campaign parameter (if present) |
utm_term | string | β π | UTM term parameter (if present) |
utm_content | string | β π | UTM content parameter (if present) |
first_touch_source | string | β π | First-touch attribution source |
first_touch_medium | string | β π | First-touch attribution medium |
first_touch_campaign | string | β π | First-touch attribution campaign |
first_touch_referrer_category | string | β π | First-touch referrer category |
browser | string | β π | Browser name (Chrome, Firefox, Safari, Edge, Opera, Unknown) |
os | string | β π | Operating system (Windows, macOS, Linux, Android, iOS, Unknown) |
language | string | β π | Browser language (navigator.language) |
timezone | string | β π | User timezone (e.g., βAmerica/New_Yorkβ) |
screen_resolution | string | β π | Screen resolution (e.g., β1920x1080β) |
viewport | string | β π | Viewport size (e.g., β1440x900β) |
timestamp | number | β | Event timestamp (milliseconds since epoch) |
_grain_session_start
Automatically tracked when a new session begins (page load).
| Property | Type | Tracking | Description |
|---|---|---|---|
session_id | string | β | Unique session identifier |
landing_page | string | β π | First page of the session |
referrer | string | β π | Referrer URL (if present) |
referrer_domain | string | β π | Referrer domain (if present) |
referrer_category | string | β π | Categorized referrer source |
utm_source | string | β π | UTM source (if present) |
utm_medium | string | β π | UTM medium (if present) |
utm_campaign | string | β π | UTM campaign (if present) |
utm_term | string | β π | UTM term (if present) |
utm_content | string | β π | UTM content (if present) |
first_touch_source | string | β π | First-touch attribution source |
first_touch_medium | string | β π | First-touch attribution medium |
first_touch_campaign | string | β π | First-touch attribution campaign |
first_touch_referrer_category | string | β π | First-touch referrer category |
screen_resolution | string | β π | Screen resolution |
viewport | string | β π | Viewport size |
browser | string | β π | Browser name |
os | string | β π | Operating system |
language | string | β π | Browser language |
timezone | string | β π | User timezone |
timestamp | number | β | Session start time |
_grain_session_end
Automatically tracked when a session ends (page unload/close).
| Property | Type | Tracking | Description |
|---|---|---|---|
session_id | string | β | Session identifier |
duration | number | β | Session duration in milliseconds |
event_count | number | β | Total events tracked during session |
page_count | number | β π | Total pages viewed during session |
timestamp | number | β | Session end time |
_grain_heartbeat
Automatically tracked at regular intervals to measure engagement.
| Property | Type | Tracking | Description |
|---|---|---|---|
heartbeat_type | string | β | Type: βperiodicβ or βpage_loadβ |
status | string | β | User activity: βactiveβ or βinactiveβ |
page | string | β π | Current page path |
session_id | string | β π | Current session identifier |
duration | number | β π | Time since last heartbeat (periodic only) |
event_count | number | β π | Events since last heartbeat (periodic only) |
timestamp | number | β | Heartbeat timestamp |
_grain_consent_granted
Tracked when user grants analytics consent.
| Property | Type | Tracking | Description |
|---|---|---|---|
previous_session_id | string | β | Ephemeral session ID before consent |
new_user_id | string | β | Persistent user ID after consent |
timestamp | number | β | Consent grant time |
Template Events
These events are available via SDK helper methods but require manual triggering.login
Track user authentication.
| Property | Type | Tracking | Description |
|---|---|---|---|
method | string | π§ | Authentication method |
success | boolean | π§ | Whether login succeeded |
errorMessage | string | π§ | Error message (if failed) |
loginAttempt | number | π§ | Login attempt number |
rememberMe | boolean | π§ | Whether βremember meβ was checked |
twoFactorEnabled | boolean | π§ | Whether 2FA is enabled |
signup
Track user registration.
| Property | Type | Tracking | Description |
|---|---|---|---|
method | string | π§ | Registration method |
source | string | π§ | Where user signed up from |
plan | string | π§ | Selected plan |
success | boolean | π§ | Whether signup succeeded |
errorMessage | string | π§ | Error message (if failed) |
purchase
Track completed purchases.
| Property | Type | Tracking | Description |
|---|---|---|---|
orderId | string | π§ | Unique order identifier |
total | number | π§ | Total order amount |
currency | string | π§ | Currency code (USD, EUR, etc.) |
items | array | π§ | Array of purchased items |
paymentMethod | string | π§ | Payment method used |
shippingMethod | string | π§ | Shipping method selected |
tax | number | π§ | Tax amount |
shipping | number | π§ | Shipping cost |
discount | number | π§ | Discount amount |
couponCode | string | π§ | Applied coupon code |
checkout
Track checkout initiation.
purchase event
search
Track search queries.
| Property | Type | Tracking | Description |
|---|---|---|---|
query | string | π§ | Search query text |
results | number | π§ | Number of results found |
filters | object | π§ | Applied filters |
sortBy | string | π§ | Sort order |
category | string | π§ | Search category |
success | boolean | π§ | Whether search succeeded |
add_to_cart
Track items added to cart.
| Property | Type | Tracking | Description |
|---|---|---|---|
itemId | string | π§ | Product ID |
itemName | string | π§ | Product name |
price | number | π§ | Unit price |
quantity | number | π§ | Quantity added |
currency | string | π§ | Currency code |
category | string | π§ | Product category |
variant | string | π§ | Product variant (color, size, etc.) |
remove_from_cart
Track items removed from cart.
Properties same as add_to_cart event
Custom Events
You can track any custom event with your own properties:Automatic Property Enrichment
Important: All custom events (except system events starting with_grain_) are automatically enriched with session-level attribution properties when user consent is granted:
- UTM Parameters:
utm_source,utm_medium,utm_campaign,utm_term,utm_content(from the current session) - First-Touch Attribution:
first_touch_source,first_touch_medium,first_touch_campaign,first_touch_referrer_category - Session ID:
session_id
Recommended Custom Properties
When tracking custom events, consider including:- Context:
page,section,component - Action details:
action_type,target,value - User state:
is_authenticated,user_plan,user_role - Experiment:
experiment_id,variant - Performance:
duration,load_time
Property Scope
Event-Scoped Properties
Properties that exist on the specific event being tracked. Most properties are event-scoped.User-Scoped Properties
Properties that exist on any event for a given user. In Matrices, you can query by βUser Property (Any Event)β to find users who have logged this property at least once, even if not on the specific event being analyzed. Examples:first_touch_*- Set on session_start, can be queried on any eventutm_*- Set on page_view, can be queried on conversion events- Custom user properties set via
grain.setProperty()
Referrer Categories
The SDK automatically categorizes referrers:- organic: Search engines (Google, Bing, Yahoo, etc.)
- paid: Paid advertising (detected via gclid, fbclid, etc.)
- social: Social media (Facebook, Twitter, LinkedIn, etc.)
- email: Email clients (Gmail, Outlook, etc.)
- referral: Other websites
- direct: No referrer (direct navigation or bookmark)
Browser Detection
Supported browsers:- Chrome
- Firefox
- Safari
- Edge
- Opera
- Unknown (for unrecognized browsers)
OS Detection
Supported operating systems:- Windows
- macOS
- Linux
- Android
- iOS
- Unknown (for unrecognized systems)
Best Practices
- Only log relevant properties: Donβt send null/undefined values
- Use consistent naming: snake_case for property names
- Include context: Add page/section/component for UI events
- Track user flow: Use consistent event names across journeys
- Test attribution: Verify UTM parameters and referrer tracking
- Respect privacy: Only collect necessary data, honor consent
Configuration
Disable Auto-Properties
To disable automatic property collection:Strip Query Parameters
To remove query params from page URLs:Property Whitelist
To limit which properties can be tracked:Need Help?
- Documentation: docs.grainql.com
- Dashboard: grainql.com/dashboard
- Issues: GitHub Issues
- Email: [email protected]