Updated 20 October 2026

Angular analytics

Privacy-first, cookieless analytics for Angular: one tag in index.html, with Angular Router navigation counted for you.

In short

  • One tag in the <head> of src/index.html. No module, no service, no change to the build.
  • Angular Router navigation is counted by itself, once per page.
  • No cookie banner needed in cookieless mode, no IP address stored, and nothing loaded from another company.

Install on Angular#

Use your own site id and server address in the code below. On trckable Cloud the address is https://cloud.trckable.com.

Put the tag in the <head> of src/index.html:

<script
  defer
  data-site="tkb_a1b2c3d4"
  data-domain="example.com"
  src="https://stats.example.com/js/tkb_a1b2c3d4.js">
</script>

To bundle the tracker instead, install trckable and start it before Angular bootstraps:

// src/main.ts
import { init } from 'trckable'

init({ site: 'tkb_a1b2c3d4', host: 'https://stats.example.com' })

bootstrapApplication(AppComponent, appConfig)

Open your site once, then run npx trckable doctor --host https://stats.example.com --site tkb_a1b2c3d4 --url https://example.com. It only reads, and tells you whether the tag is on the page and the server answers.

What to know about Angular#

  • The router is counted. Angular's default location strategy uses the history API, and trckable counts the route change.
  • HashLocationStrategy needs a switch. Add data-hash to the tag and turn on Settings → General → Reports → Pages after the #.
  • ng serve is ignored because trckable does not count localhost unless the tag has data-dev.
  • If you send a Content Security Policy, allow the script and the events: script-src and connect-src for your trckable address. With a same-origin proxy, 'self' is enough.
  • Server-side rendering is fine. The tag sits in the HTML Angular sends; the script itself runs only in the browser.

Goals and revenue#

A goal needs no code: put an attribute on the element and each click is counted.

<button data-trckable-goal="signup" data-trckable-goal-plan="pro">Start trial</button>

Connect Stripe, Paddle, Lemon Squeezy, Polar or Dodo Payments with one key, and each payment is credited to the visit that earned it, so revenue shows next to traffic. See revenue attribution.

Questions#

Do I need to inject anything into Angular?
No. The tag is a plain script in index.html, and goals can be plain attributes such as data-trckable-goal="signup" on a button.
Do I need a cookie banner on my Angular site?
Not for the counting itself. In cookieless mode (add data-cookieless to the tag) nothing is stored on the visitor's device and no IP address is kept. Whether your site needs a banner for other reasons is a question for your own situation; the cookie banner guide explains the rules in plain words.
Can ad blockers stop it?
A blocker can block any script, and trckable does not claim otherwise. Sending events through your own domain removes the separate analytics file a blocklist would match by name, which is the accurate setup. The same-origin proxy guide shows how.
Is it free for a Angular site?
The server is open source and free to self-host, and the tracker is MIT licensed. If you would rather not run a server, trckable Cloud runs it for you; the plans are on the pricing page.

Keep reading#

Other stacks#

Start free