Install on Flutter
A NavigatorObserver on your MaterialApp counts the first route and every push, pop and replace after it.
Before you paste anything
Every snippet below shows YOUR-SITE-ID
. Replace it with your own site id, which is on the Tracking Code page of the site in your account.
If you do not have an account yet, creating one and adding your domain takes about a minute.
Check that the data is arriving
- Open your site in a browser and load any page.
- In VeritaMetrics, open the site and click Tracking Code in the sidebar. The status turns active and your visit appears in the recent-pageviews list within a few seconds.
If nothing arrives, open your browser devtools on the Network tab and reload. You should see a request to /api/tracker.js that returns 200, then a request to /api/v1/c when you move or scroll.
This is the web target only
The observer uses dart:html, which does not exist on iOS, Android or desktop builds, so importing it unconditionally breaks those builds rather than sending nothing. Keep it behind a conditional import, or in a file only the web entrypoint reaches.
Guides for other platforms
The same install, on a different stack.
Explore the documentation
Jump to another guide.