Skip to content
Features Integrations Pricing Docs

Events & revenue

Beyond page views, byanalytics records custom events, outbound links, file downloads and internal site searches.

Automatic events

Event When
outbound A visitor clicks a link to another domain (url property).
download A visitor clicks a file link (pdf, zip, csv, docx, mp4…).
engagement Time the page was visible, sent when the visitor leaves. Used for visit duration.

Internal searches are detected from the URL query parameters configured for the site (q, s, search by default) and appear in the Search terms report.

Declarative events (no JavaScript)

Add data-ba-event to any element. Every other data-ba-* attribute becomes a property:

<button data-ba-event="signup" data-ba-plan="pro">Start trial</button>

JavaScript API

window.byanalytics('event', 'signup', { plan: 'pro' })

To call the API before the script has loaded, add this stub before the snippet:

<script>
  window.byanalytics = window.byanalytics || function () {
    (window.byanalytics.q = window.byanalytics.q || []).push(arguments)
  }
</script>

You can also trigger a manual page view with window.byanalytics('pageview').

Properties

  • Up to 30 flat properties per event (strings, numbers or booleans).
  • Names up to 40 characters (letters, digits, _ and -); values are cut at 200 characters.
  • Never send personal data (names, emails, IDs that identify a person) as properties.

Revenue

A numeric value (or revenue) property is added to the Revenue metric of the site:

window.byanalytics('event', 'purchase', { value: 49.90, currency: 'EUR' })

Revenue is shown per page, source and campaign so you can see which channels pay off.

UTM campaigns

utm_source, utm_medium, utm_campaign, utm_term and utm_content are read from the landing URL and attributed to the whole visit.