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
pagestringβœ…Current 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
browserstringβœ… πŸ”’Browser name (Chrome, Firefox, Safari, Edge, Opera, Unknown)
osstringβœ… πŸ”’Operating system (Windows, macOS, Linux, Android, iOS, Unknown)
languagestringβœ… πŸ”’Browser language (navigator.language)
timezonestringβœ… πŸ”’User timezone (e.g., β€œAmerica/New_York”)
screen_resolutionstringβœ… πŸ”’Screen resolution (e.g., β€œ1920x1080”)
viewportstringβœ… πŸ”’Viewport size (e.g., β€œ1440x900”)
timestampnumberβœ…Event timestamp (milliseconds since epoch)

_grain_session_start

Automatically tracked when a new session begins (page load).
PropertyTypeTrackingDescription
session_idstringβœ…Unique 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
browserstringβœ… πŸ”’Browser name
osstringβœ… πŸ”’Operating system
languagestringβœ… πŸ”’Browser language
timezonestringβœ… πŸ”’User timezone
timestampnumberβœ…Session start time

_grain_session_end

Automatically tracked when a session ends (page unload/close).
PropertyTypeTrackingDescription
session_idstringβœ…Session identifier
durationnumberβœ…Session duration in milliseconds
event_countnumberβœ…Total events tracked during session
page_countnumberβœ… πŸ”’Total pages viewed during session
timestampnumberβœ…Session end time

_grain_heartbeat

Automatically tracked at regular intervals to measure engagement.
PropertyTypeTrackingDescription
heartbeat_typestringβœ…Type: β€œperiodic” or β€œpage_load”
statusstringβœ…User 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)
timestampnumberβœ…Heartbeat timestamp

Tracked when user grants analytics consent.
PropertyTypeTrackingDescription
previous_session_idstringβœ…Ephemeral session ID before consent
new_user_idstringβœ…Persistent user ID after consent
timestampnumberβœ…Consent 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 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
This ensures that all events have the necessary 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',
  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?