Custom events, goals and revenue
Pageviews are counted automatically. To count actions such as signups, call foresite():
foresite('signup')
Properties
Add properties to break an event down further:
foresite('signup', { props: { plan: 'pro', source: 'pricing-page' } })
Properties are shown on the dashboard by event. Never put personal data in properties. Values that look like email addresses, phone numbers, card numbers or IP addresses are discarded automatically, and the dashboard warns you if that happens.
Revenue
Attach an amount to an event to see revenue on the dashboard:
foresite('purchase', { revenue: { amount: 49.99, currency: 'USD' } })
The currency must match your site's currency (Settings → General). Amounts in any other currency are ignored, so totals are never mixed.
Calling foresite() before the script loads
If your code might run before Foresite has loaded, add this line once, above your Foresite script:
<script>window.foresite=window.foresite||function(){(foresite.q=foresite.q||[]).push(arguments)}</script>
Calls made early are queued and sent as soon as Foresite loads.
Goals
A Goal marks a page or an event as a success, such as /thank-you or signup. Add Goals in Settings → Goals; the dashboard then shows how many visitors reached each one, and the conversion rate. Page goals ending in * match every page starting with that path, e.g. /blog/*.
Custom events count toward your monthly price, just like pageviews.