Skip to main content
For interactions or data points beyond the built‑ins (sessions, links, orientation), use the Manual Events API to push any custom event to Experro Analytics.

Pushing an Event

If you need to track custom events, call the following snippet after listening to the exp-analytics-loaded event:

ExpAnalyticsService.trackEvent({
  event_name: "Event Name",      // String: your custom event key
  count: count,                  // Number: integer occurrences
  sum: sum,                      // Number: numeric value to aggregate (default 0)
  dur: dur,                      // Number: duration in seconds (default 0)
  event_data: eventData          // Object: arbitrary key/value pairs
});
  • event_name A unique string identifier for your event (e.g. "product_clicked", "checkout_started").
  • count How many times this event should be counted (often 1 for discrete actions).
  • sum A numeric value to aggregate—useful for revenue, scores, or any measurable metric.
  • dur Duration in seconds—track time‑on‑task, video playtime, or other time‑based metrics.
  • event_data An object of custom dimensions or attributes (strings, numbers, or arrays). For example:
    event_data: {
      product_id: 'SKU-123',
      category:   't-shirts',
      price:      19.99,
      promo:      ['summer_sale', 'vip_user']
    }
    

Example: Tracking a Button Click

<button id="buy-now">Buy Now</button>
<script>
  document.getElementById('buy-now').addEventListener('click', () => {
    ExpAnalyticsService.trackEvent({
      event_name:'purchase_initiated',
      count: 1,
      sum: 49.99,
      event_data: {
        sku: 'TSHIRT-XL',
        color: 'blue'
      }
    })
  });
</script>
This pushes a single purchase_initiated event, increments its count by 1, adds the purchase amount to your sum metric, and attaches product details via segmentation. Once you’ve got custom events flowing, you can review them in the Experro Analytics dashboard or proceed to the next section to see our built‑in E‑Commerce and Auth event keys and their expected payloads.