Skip to content

Tracking script

The PureMetrix tracking script is a tiny file (under 3 KB) that loads after your page (deferred), so it does not slow it down. Load it from https://collect.puremetrix.org or through your same-origin proxy.

Basic snippet

<script defer data-domain="example.com" data-key="YOUR_PUBLIC_KEY"
  src="https://collect.puremetrix.org/js/script.js"></script>

Copy the domain and public key from Site settings → General in https://app.puremetrix.org. Optional data attributes:

  • data-outbound="true" — outbound link events
  • data-downloads="true" — file download events
  • data-forms="true" — form submit events
  • data-scroll="true" — scroll depth milestones
  • data-hash="true" — pageviews for sites that change pages via # in the URL (some single-page apps)

Turn these on under Site settings → General → Tracking; the app then updates the recommended snippet for you.

Custom events

puremetrix('signup');
puremetrix('404');

Turn custom events into goals under Goals. Events sent from your server (for example a WooCommerce Purchase) use the same collect endpoint with your public key.

Related