Skip to content

Send your own events

Count things people do with one line of code, with details and revenue, and use them in goals.

How-to guide2 min read

Once the script is on the page, insights.track sends an event:

JavaScript
insights.track('Signed up', { plan: 'growth' });
  • The name is how the event is shown and how goals find it, so use plain words, such as Signed up or Brochure requested. Up to 120 characters.
  • The details are optional: up to 30, each named in up to 64 characters, with text of up to 500 characters, a number or true or false. A batch with an event over these limits is refused as a whole, so keep details short. Don't send names, email addresses or other personal data.

Before the script has loaded

The script loads with defer, so insights may not exist yet when your code runs. Queue the call instead, and the script sends it once it loads:

JavaScript
window.insights = window.insights || { q: [] };window.insights.q.push(['track', 'Brochure requested', { trip: 'lofoten-ski-touring' }]);

Or call window.insights?.track(…) where losing an event before the script loads doesn't matter.

From a server

For things that happen on a server, such as a payment confirmed by your payment provider, send the event to the server API instead. It needs no browser, so it also counts what an ad blocker would hide.

Revenue

Add revenue and its currency as a third argument:

JavaScript
insights.track('Order placed', { items: 3 }, { revenue: 49, currency: 'EUR' });

Goals that use the event then show the revenue as their value. Use the three-letter currency code, in capitals, of the money the visitor paid in. Revenue can't be negative and always needs its currency. Revenue is added up per currency and never converted, so a shop that sells in euros and pounds sees both totals.

See your events

Events in Insights Orbit lists every event with how often it was sent, by how many visitors and in how many visits. Open one to see its details and how often each value came up.

Automatic events, such as Outbound link and Form sent, show up there too, marked Automatic.

Turn an event into a goal

Under Goals, choose Sends an event and give the event's name, optionally with a detail that has to match. See Set up goals.

Signed-in people

On the Enterprise plan, a website where people sign in can attach its own user id to events with insights.identify. See Send user ids for known users.

Was this page helpful?

Read next