Skip to main content

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.
PropertyTypeTrackingDescription
pagestringCurrent page path (with or without query params based on config)
titlestring✅ 🔒Document title
full_urlstring✅ 🔒Complete URL including query params and hash
referrerstring✅ 🔒Previous page URL (document.referrer)
referrer_domainstring✅ 🔒Domain extracted from referrer
referrer_categorystring✅ 🔒Categorized referrer: organic, paid, social, direct, email, referral
previous_pagestring✅ 🔒Previous page within the same session
landing_pagestring✅ 🔒First page of the session (only on subsequent page views)
session_idstring✅ 🔒Current session identifier
utm_sourcestring✅ 🔒UTM source parameter (if present)
utm_mediumstring✅ 🔒UTM medium parameter (if present)
utm_campaignstring✅ 🔒UTM campaign parameter (if present)
utm_termstring✅ 🔒UTM term parameter (if present)
utm_contentstring✅ 🔒UTM content parameter (if present)
first_touch_sourcestring✅ 🔒First-touch attribution source
first_touch_mediumstring✅ 🔒First-touch attribution medium
first_touch_campaignstring✅ 🔒First-touch attribution campaign
first_touch_referrer_categorystring✅ 🔒First-touch referrer category
devicestringDevice type (Mobile, Tablet, Desktop)
browserstringBrowser name (Chrome, Firefox, Safari, Edge, Opera, Unknown)
osstringOperating system (Windows, macOS, Linux, Android, iOS, Unknown)
languagestringBrowser language (navigator.language)
timezonestringUser timezone (e.g., “America/New_York”)
screen_resolutionstringScreen resolution (e.g., “1920x1080”)
viewportstringViewport size (e.g., “1440x900”)
timestampnumberEvent timestamp (milliseconds since epoch)

_grain_session_start

Automatically tracked when a new session begins (page load).
PropertyTypeTrackingDescription
session_idstringUnique session identifier
landing_pagestring✅ 🔒First page of the session
referrerstring✅ 🔒Referrer URL (if present)
referrer_domainstring✅ 🔒Referrer domain (if present)
referrer_categorystring✅ 🔒Categorized referrer source
utm_sourcestring✅ 🔒UTM source (if present)
utm_mediumstring✅ 🔒UTM medium (if present)
utm_campaignstring✅ 🔒UTM campaign (if present)
utm_termstring✅ 🔒UTM term (if present)
utm_contentstring✅ 🔒UTM content (if present)
first_touch_sourcestring✅ 🔒First-touch attribution source
first_touch_mediumstring✅ 🔒First-touch attribution medium
first_touch_campaignstring✅ 🔒First-touch attribution campaign
first_touch_referrer_categorystring✅ 🔒First-touch referrer category
screen_resolutionstring✅ 🔒Screen resolution
viewportstring✅ 🔒Viewport size
devicestringDevice type (Mobile, Tablet, Desktop)
browserstringBrowser name
osstringOperating system
languagestring✅ 🔒Browser language
timezonestring✅ 🔒User timezone
timestampnumberSession start time

_grain_session_end

Automatically tracked when a session ends (page unload/close).
PropertyTypeTrackingDescription
session_idstringSession identifier
durationnumberSession duration in milliseconds
event_countnumberTotal events tracked during session
page_countnumber✅ 🔒Total pages viewed during session
timestampnumberSession end time

_grain_heartbeat

Automatically tracked at regular intervals to measure engagement.
PropertyTypeTrackingDescription
heartbeat_typestringType: “periodic” or “page_load”
statusstringUser activity: “active” or “inactive”
pagestring✅ 🔒Current page path
session_idstring✅ 🔒Current session identifier
durationnumber✅ 🔒Time since last heartbeat (periodic only)
event_countnumber✅ 🔒Events since last heartbeat (periodic only)
timestampnumberHeartbeat timestamp

Tracked when user grants analytics consent.
PropertyTypeTrackingDescription
previous_session_idstringEphemeral session ID before consent
new_user_idstringPersistent user ID after consent
timestampnumberConsent grant time

Template Events

These events are available via SDK helper methods but require manual triggering.

login

Track user authentication.
grain.trackLogin({
  method: 'email', // or 'google', 'facebook', etc.
  success: true,
  errorMessage: 'Invalid credentials', // if success = false
  loginAttempt: 1,
  rememberMe: true,
  twoFactorEnabled: false,
});
PropertyTypeTrackingDescription
methodstring🔧Authentication method
successboolean🔧Whether login succeeded
errorMessagestring🔧Error message (if failed)
loginAttemptnumber🔧Login attempt number
rememberMeboolean🔧Whether “remember me” was checked
twoFactorEnabledboolean🔧Whether 2FA is enabled

signup

Track user registration.
grain.trackSignup({
  method: 'email',
  source: 'landing_page',
  plan: 'free',
  success: true,
});
PropertyTypeTrackingDescription
methodstring🔧Registration method
sourcestring🔧Where user signed up from
planstring🔧Selected plan
successboolean🔧Whether signup succeeded
errorMessagestring🔧Error message (if failed)

purchase

Track completed purchases.
grain.trackPurchase({
  orderId: 'ORD-12345',
  total: 99.99,
  currency: 'USD',
  items: [
    { id: 'ITEM-1', name: 'Product A', price: 49.99, quantity: 2, category: 'electronics' }
  ],
  paymentMethod: 'credit_card',
  shippingMethod: 'express',
  tax: 8.50,
  shipping: 5.99,
  discount: 10.00,
  couponCode: 'SAVE10',
});
PropertyTypeTrackingDescription
orderIdstring🔧Unique order identifier
totalnumber🔧Total order amount
currencystring🔧Currency code (USD, EUR, etc.)
itemsarray🔧Array of purchased items
paymentMethodstring🔧Payment method used
shippingMethodstring🔧Shipping method selected
taxnumber🔧Tax amount
shippingnumber🔧Shipping cost
discountnumber🔧Discount amount
couponCodestring🔧Applied coupon code

checkout

Track checkout initiation.
grain.trackCheckout({
  orderId: 'ORD-12345',
  total: 99.99,
  currency: 'USD',
  items: [/* ... */],
  paymentMethod: 'credit_card',
  success: true,
});
Properties same as purchase event
Track search queries.
grain.track('search', {
  query: 'wireless headphones',
  results: 42,
  filters: { category: 'electronics', price: 'under-50' },
  sortBy: 'popularity',
  category: 'products',
  success: true,
});
PropertyTypeTrackingDescription
querystring🔧Search query text
resultsnumber🔧Number of results found
filtersobject🔧Applied filters
sortBystring🔧Sort order
categorystring🔧Search category
successboolean🔧Whether search succeeded

add_to_cart

Track items added to cart.
grain.trackAddToCart({
  itemId: 'PROD-123',
  itemName: 'Wireless Headphones',
  price: 49.99,
  quantity: 1,
  currency: 'USD',
  category: 'electronics',
  variant: 'black',
});
PropertyTypeTrackingDescription
itemIdstring🔧Product ID
itemNamestring🔧Product name
pricenumber🔧Unit price
quantitynumber🔧Quantity added
currencystring🔧Currency code
categorystring🔧Product category
variantstring🔧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:
grain.track('button_clicked', {
  button_id: 'signup-cta',
  button_text: 'Get Started',
  page: '/pricing',
  position: 'hero',
});
New to event naming? Check out our Event Naming Convention guide for a systematic approach to naming custom events. It provides a hierarchical structure that makes events clear, consistent, and easy to query.

Automatic Property Enrichment

Important: All custom events (except system events starting with _grain_) are automatically enriched with the following properties: Always included (no consent required):
  • Device Info: device (Mobile/Tablet/Desktop), browser, os
Included 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
This ensures that all events have device context and attribution data for matrix analysis and conversion tracking, even if you don’t explicitly include these properties in your custom events. Example: When you track a signup event:
grain.track('signup', { plan: 'pro' });
The actual event sent will include:
{
  plan: 'pro',
  device: 'Desktop',            // Auto-added (always)
  browser: 'Chrome',            // Auto-added (always)
  os: 'macOS',                  // Auto-added (always)
  utm_source: 'google',         // Auto-added from session
  utm_medium: 'cpc',            // Auto-added from session
  utm_campaign: 'spring_sale',  // Auto-added from session
  first_touch_source: 'google', // Auto-added
  first_touch_campaign: 'spring_sale', // Auto-added
  session_id: '...',            // Auto-added
  // ... other first-touch 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 event
  • utm_* - 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

  1. Only log relevant properties: Don’t send null/undefined values
  2. Use consistent naming: snake_case for property names
  3. Include context: Add page/section/component for UI events
  4. Track user flow: Use consistent event names across journeys
  5. Test attribution: Verify UTM parameters and referrer tracking
  6. Respect privacy: Only collect necessary data, honor consent

Configuration

Disable Auto-Properties

To disable automatic property collection:
const grain = createGrainAnalytics({
  tenantId: 'your-tenant-id',
  disableAutoProperties: true,
});

Strip Query Parameters

To remove query params from page URLs:
const grain = createGrainAnalytics({
  tenantId: 'your-tenant-id',
  stripQueryParams: true, // default: true
});

Property Whitelist

To limit which properties can be tracked:
const grain = createGrainAnalytics({
  tenantId: 'your-tenant-id',
  allowedProperties: ['page', 'button_id', 'action'],
});

Need Help?