Skip to main content
Create one root service. It starts Bily only in the browser. Do not add the raw Bily script to index.html. The SDK owns script loading for this installation path.

Install Bily

Keep one public configuration value

Add the complete tracking URL to the public environment configuration your Angular build already uses.
src/environments/environment.ts
The URL is public installation data. It is not a private token. If your build replaces environment files, set the complete value for every preview and production target.

Initialize in the browser

src/app/bily-tracking.service.ts
isPlatformBrowser() keeps initialization out of server rendering.

Start the service once

Inject the service from the root component. Keep the component’s existing imports, template, providers, and application shell.
src/app/app.component.ts
If your root component already exists, add only the import and constructor parameter. Do not replace its metadata or template with this minimal example. The browser script records the initial page and supported client-side navigation automatically. Do not add manual PageView calls for those navigations; use track() for business events.

Track successful actions

src/app/save-profile.component.ts

Rebuild after a URL change

Angular environment values are normally compiled into browser assets. After Bily validates a customer subdomain, replace the complete value and rebuild every affected target.

Verify Angular tracking

Check server rendering, initial load, successful routes, and action events.

Move to first-party tracking

Replace the URL once, rebuild, deploy, and verify the new request.