Angular Integration
Add Ovyxa analytics to your Angular application via index.html or the angular.json scripts configuration.
Option 1: Via index.html (Recommended)
Add the tracking script to your src/index.html file, just before the closing </head> tag:
src/index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Angular App</title>
<!-- ... other head elements ... -->
<script
defer
data-domain="yourdomain.com"
src="https://ovyxa.com/js/script.js"
></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
Option 2: Via angular.json
Add the script to the scripts array in angular.json:
angular.json
{
"projects": {
"my-app": {
"architect": {
"build": {
"options": {
"scripts": [
{
"input": "https://ovyxa.com/js/script.js",
"inject": true
}
]
}
}
}
}
}
}
Note: The index.html approach is preferred because it preserves the data-domain and defer attributes.
Tracking Custom Events
Create a reusable service for tracking:
src/app/ovyxa.service.ts
import { Injectable } from '@angular/core'
declare global {
interface Window { ovyxa: (event: string, name: string, options?: object) => void }
}
@Injectable({ providedIn: 'root' })
export class OvyxaService {
trackEvent(name: string, props?: Record<string, string>) {
window.ovyxa?.('event', name, props ? { props } : undefined)
}
}
Use it in any component:
constructor(private ovyxa: OvyxaService) {}
onSignup() {
this.ovyxa.trackEvent('Signup', { plan: 'growth' })
}
Cookieless Mode
Add data-cookieless to skip cookie consent requirements:
<script
defer
data-domain="yourdomain.com"
data-cookieless
src="https://ovyxa.com/js/script.js"
></script>
Verify Installation
- Serve your app (
ng serve) or deploy it - Visit the app in your browser
- Open the browser Network tab and look for a request to
ovyxa.com/js/script.js - Check your Ovyxa dashboard to confirm pageviews are appearing