文档
浏览文档

Add Privatus Analytics to Ember.js

Add cookieless analytics to an Ember.js app with one script tag in app/index.html, with router transitions counted as page views automatically.

查看 Markdown

Open app/index.html and add the snippet inside <head>:

html
<script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>

Rebuild and deploy. Ember apps run on one HTML file, so the tag is on every route.

Ember's router uses the History API by default, and the tracker follows history.pushState with its default data-spa="auto". If you set locationType to hash, route-like fragments (#/…) are followed too. See single-page apps.

The tracker ignores localhost while you run ember serve, so you don't need a production check. To track from a development host, see attributes.

Track events from a component with window.privatus?.track('Name'). See the JavaScript API.