Custom events
A custom event is a named thing a visitor did: a signup, a purchase, a click on the pricing toggle. Events show up on the Events screen with their counts, and any event can be a goal.
Tracking an event
lynq.track(name, properties?) records one event:
lynq.track("signup");
lynq.track("purchase", { plan: "pro", revenue: 49 });window.lynq exists once the script has loaded. If you need to call it earlier, queue instead; the queue is drained when the script starts:
window.lynqQueue = window.lynqQueue || [];
window.lynqQueue.push({ name: "signup", properties: { plan: "pro" } });Names and properties
- The name is a string of up to 64 characters. Keep it stable and lowercase; it is what the Events screen groups by.
- Properties are a flat object: at most 20 keys, each key up to 32 characters, each value stored as text up to 256 characters. Numbers and booleans are stored as their text. Nested objects, arrays and
nullare dropped. - Every property is filterable: the Events screen breaks an event down by any property, and a filter
prop:plan is proworks on every screen.
Revenue
A numeric revenue property, such as 49 or 49.90, is also stored as revenue, and revenue per visitor is shown beside it.
Revenue attaches to the pageview whose event carried it, so it appears where a whole session can be credited: the Sources tables, the Pages screen’s Entry view, the goal’s page, and the Show-all view and CSV on Locations. It is deliberately absent from the all-pages and exit views, where it would pile onto the checkout page and say where the event fired rather than which page led to money.
There is no currency handling; report every amount in one currency.
Declarative events
With data-auto-events on the script tag, an element with data-lynq-event records that event when clicked, with data-lynq-prop-* attributes as properties:
<a href="/pricing" data-lynq-event="pricing_click" data-lynq-prop-plan="pro">See pricing</a>records pricing_click with { plan: "pro" }. The click bubbles, so an element inside the link counts too. This is the way to add events to a page you cannot add JavaScript to.
Outbound links and downloads
With data-outbound on the script tag, a click on a link to another host records outbound, and a click on a file link (by extension, or with a download attribute) records download. Both carry the url property. They appear on the Events screen like any other event.